Java Bottled Water Calculator

Assignment's Price
$15

Order Description

According to a recent TV commercial, Americans consumed so much bottled water last year that the bottles – if laid end-to-end – would circle the Earth 190 times at the Equator!  One can only imagine how disruptive this would be for folks actually living at the Equator!  Anyway, approximately how many bottles is that, and what is the average amount of water consumed by each American?  Let’s write a program to find out!  Better yet, let’s write a program that computes this information for any country.

 

Given this data

 

  1. the name of the country
  2. the population of the country
  3. the number of times the bottles would circle the earth
  4. the average length of a bottle, in inches
  5. the average volume of a bottle, in fluid ounces

 

your program will compute

 

  1. the total number of bottles used
  2. the average amount of water consumed per person, in gallons

 

Your program will consist of a BottledWaterCalculator class and a “tester” class.

 

 

  1. Your BottledWaterCalculator Class - Specifications

 

  1. Your class will have private instance variables that store the data listed above (1 - 5)

 

  1. All numeric instance variables are to be type double except for the population, which is an int

 

  1. Instance variables are to be initialized to values passed to the class constructor

 

  1. Your class will have accessor (“get”) methods to return the values of each of the instance variables

 

  1. Your class will have 2 methods that compute and return the outputs (a and b) listed above

 

  1. Your class will also have a mutator (“set”) method that changes the average length and volume of the bottles to new values passed as parameters

  

  1. Note that your BottledWaterCalculator class doesn’t do any output. All output is to be done in your test class.

 

 

III. Your Test Class

 

In the main method of your test class, write statements to accomplish each of the following, in order

 

  1. Create a BottledWaterCalculator object, using the data below
  2. Call the accessor methods to get each of the data values and then print them
  3. Call the 2 methods that compute and return the 2 outputs and print them
  4. Call the mutator method to change the bottle data.  Do notcreate a new object.  Modify the existing one 
  5. Call the accessor methods to get the new average bottle length and volume, and print them
  6. Call again the 2 methods that compute and return the 2 outputs and print them

 

  1. Although your BottledWaterCalculator must work for all valid input values, use this data in the run you hand in:

 

                        Country:  USA

                     Population:  350 million

       Number of Circumferences:  190

    Length of an Average Bottle:  8.5 inches

    Volume of an Average Bottle:  12 ounces

 

         Modified Bottle Length:  9 inches

         Modified Bottle Volume:  16.9 ounces

 

 

IV. For Reference

 

  There are 128 ounces in a gallon, and the circumference of the Earth at the Equator is 24,902 miles.  Since these values will not change, they should be literals (or defined constants, which will be covered soon) and not instance variables