Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The management of a certain chain of supermarkets would like to know on a comparative basis the performance of its supermarkets in each city. The

The management of a certain chain of supermarkets would like to know on a comparative basis the performance of its supermarkets in each city. The data in the following table shows the amount of profit for all the supermarkets in each city.

 

City                                Profit

Miami                            $10,200,000.00

Sunrise                           $14,600,000.00

Hollywood                    $17,000,000.00

Tallahassee                   $$6,000,000.00

Jacksonville                  $21,600,000.00

Orlando                         $9,100,000.00

Gainesville                    $8,000,000.00

Pensacola                      $12,500,000.00

Ocala                             $2,000,000.00

Sebring                           $4,500,000.00

 

The information required must be presented in the following order:

Display the original data set, as shown in the table.

The average profit for the supermarket chain.

The city with the highest profit.

A list of all the cities with profit at, or above the average.

The standard deviation of the profits.

The cities and their profit listed in descending order of the profits.

Find the profit for any given city.

 

To carryout this exercise:

Design a class called Supermarkets that accepts two arrays - one containing the names of the cities, and the other containing the profits. Write separate methods for each of the seven (7) activities stated in the list of requirements.

 

Design a test class called TestSupermarket that:

 

Reads the data using the class GetData

Creates a Supermarket object using the arrays as arguments to its constructor. 

Call the respective methods to carry out the requirements.

 

Using the example discussed in class, note the following:

The standard deviation is the square root of the sum of the squared difference of 

an observation and the mean, divided by the number of observations. 

That is,

s = Ö(S(xi - ū )2/N),  i є [0, MAX]

The expression S(xi - ū)2 can be expressed as follows:

sumDifference = sumDifference + Math.pow((rainfall [i] - mean), 2);

where:

(xi - ū)2   is Math.pow((rainfall [i] - mean), 2);

 xi  - is rainfall [i]

ū  - is the mean (average) that was already calculated, and

MAX - is rainfall.length - 1

 

// The following may help you.

double standardDeviation()

{

      double sumDifference = 0;

      double mean = average();

     

     for (int i = 0; i < rainfall.length; i++)

             sumDifference = sumDifference + Math.pow((rainfall [i] - mean), 2);

 

     return Math.sqrt(sumDifference/(rainfall.length - 1));   

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis And Decision Making

Authors: Christian Albright, Wayne Winston, Christopher Zappe

4th Edition

538476125, 978-0538476126

More Books

Students also viewed these Programming questions