What would the answer look like in Java?
Assignment 6
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.
able[[City,Profit],[Miami,$10,200,000.00
Assignment 6
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 Miami Sunrise Hollywood Tallahassee Jacksonville Orlando Gainesville Pensacola Ocala Sebring
ayoug $10,200,000,00 $14,600,000,00 $17,000,000,00 $$6,000,000,00 $21,600,000,00 $9,100,000.00 $8,000,000.00 $12,500,000,00 $2,000,000.00 $4,500,000,00
The information required must be presented in the following order: Display the original data set, as shown in the table. 2 The average profit for the supermarket chain. 3. The city with the highest profit. list of all the cities with profit at, or above the average. 5. The standard deviation of the profits 1 The cities and their profit listed in descending order of the profits. 7. Find the profit for any given city.
To carryout this exercise: (a 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.
(b Design a test class called TestSuperuarket that:
i. ii. iii.
Reads the data using the class GetData Creates a Superucarket 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 bf an observation and the mean, divided by the number of observations. That is, s=x/N,ic[0,MAX] The expression (x;-i can be expressed as follows: sumDifference = sumDifference + Math.pow((rainfall [i] - mcan), 2); where:
xis Math.powrainfall[i]-mean,2; X; - is rainfall [i] - is the mean (average) that was already calculated, and MAX - is rainfall.length 1
// The following may help you. double standardDeviationO
double sumDifference = 0 double mean = averageO;
for (int i =O; i < rainfall.length; i++) sumDifference = sumDifference + Math.pow((rainfall [i] - mean, 2);
return Math.sqrt(sumDifference/(rainfall.length 1));: