The purpose of this assignment is for you to understand:
(a) The concept of arrays
(b) One-dimensional arrays
(c) The concept of searching
(d) The concept of sorting

The assignment
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 of 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:
1. Make a backup copy of the original arrays.
2. Display the original data set, as shown in the table.
3. The average profit for the supermarket chain.
4. The city with the highest profit.
5. A list of all the cities with profit at, or above the average.
6. The cities and their profit listed in descending order of the profits.
7. Make a horizontal graph showing the performance of each supermarket

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 six (6) activities stated in the list of requirements.

(b) Design a test class called TestSupermarket that creates a Supermarket object using the arrays as arguments to its constructor. Call the respective methods to carry.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

public class Supermarkets
    String[] Cities = null;
    double[] Profits = null;
    String[] CitiesBackup = null;
    double[] ProfitsBacup = null;
    DecimalFormat formatter = null;
    public Supermarkets(String[] argCities , double[] argProfits)
       Cities = argCities;
       Profits = argProfits;
       formatter = new DecimalFormat("#,###.00");
    public void MakeBackupCopy()
       if(CitiesBackup == null && ProfitsBacup == null)
            CitiesBackup = new String[Cities.length];
            ProfitsBacup = new double[Profits.length];
            for(int i = 0 ; i < Cities.length ; i++)

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats