Question

code in python I. Problem Statement According to a recent TV commercial, Americans consumed so much...

code in python


I. Problem Statement

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

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

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


II. Your BottledWaterCalculator Class - Specifications

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

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

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

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

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

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

 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 not create 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

 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: 10 inches
Modified Bottle Volume: 15 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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Write a Bottle class. The class has these 14 methods: read0, set(int), set(Bottle), get0, and(Bottle), subtract(Bottle), multThe Code: import java.util.scann otle class // test driver for theBottle class public class BottleDemo3 public static void maThe Code: System.out.println(Please enter a number for bottle2:; bottle2.read(); bottle3- bottle3.add(bottle1); bottle3 - boThe Code: nd bottle2 are equal.) else System.out.println(Bottle1 a nd bottle2 are not equal.); System.out.println(Bottle4The Code: bottle5 is bottle5 + .); ger to add to the value bottle1 has.); be put in bottle3.); System.out.println(Ente

Add a comment
Know the answer?
Add Answer to:
code in python I. Problem Statement According to a recent TV commercial, Americans consumed so much...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Define a class named Payment that contains an instance variable "paymentAmount" (non-static member variable) of type...

    Define a class named Payment that contains an instance variable "paymentAmount" (non-static member variable) of type double that stores the amount of the payment and appropriate accessor (getPaymentAmount() ) and mutator methods. Also create a method named paymentDetails that outputs an English sentence to describe the amount of the payment. Override toString() method to call the paymentDetails() method to print the contents of payment amount and any other details not included in paymentDetails(). Define a class named CashPayment that is...

  • IN PYTHON Assignment Overview This assignment will give you experience on the use of classes. Understand...

    IN PYTHON Assignment Overview This assignment will give you experience on the use of classes. Understand the Application The assignment is to first create a class calledTripleString.TripleStringwill consist of threeinstance attribute strings as its basic data. It will also contain a few instance methods to support that data. Once defined, we will use it to instantiate TripleString objects that can be used in our main program. TripleString will contain three member strings as its main data: string1, string2, and string3....

  • Problem 1 Write a program that outputs the lyrics for “Ninety-nine Bottles of Beer on the...

    Problem 1 Write a program that outputs the lyrics for “Ninety-nine Bottles of Beer on the Wall.” Your program should print the number of bottles in English, not as a number. For example: Ninety-nine bottles of beer on the wall, Ninety-nine bottles of beer, Take one down, pass it around, Ninety-eight bottles of beer on the wall. ... One bottle of beer on the wall, One bottle of beer, Take one down, pass it around, Zero bottles of beer on...

  • Lab 1: InheritanceTest Write a program called InheritanceTest1.java to support an inheritance hierarchy for class Point–Square–Cube....

    Lab 1: InheritanceTest Write a program called InheritanceTest1.java to support an inheritance hierarchy for class Point–Square–Cube. Use Point as the superclass of the hierarchy. Specify the instance variables and methods for each class. The private data of Point should be the x-y coordinates, the private data of Square should be the sideLength, and the private data of Cube should be depth. Provide applicable accessor methods, mutator methods, toString() methods, area() method, and volume() method to all classes. Write a program...

  • JAVA :The following are descriptions of classes that you will create. Think of these as service...

    JAVA :The following are descriptions of classes that you will create. Think of these as service providers. They provide a service to who ever want to use them. You will also write a TestClass with a main() method that fully exercises the classes that you create. To exercise a class, make some instances of the class, and call the methods of the class using these objects. Paste in the output from the test program that demonstrates your classes’ functionality. Testing...

  • In Java For the following questions, “define a class” means the following: • Create an appropriately-named...

    In Java For the following questions, “define a class” means the following: • Create an appropriately-named file containing the Java class definition, including the following: – A block comment describing the file (and hence the class), as always – Any instance variables, as required by the question – Accessor (getter) and mutator (setter) methods for any instance variables – Constructors as appropriate or as required by the question – A toString method that prints instances of the class informatively –...

  • Python 3 IDE/AWS Problem You are tasked with writing a new program for your company that...

    Python 3 IDE/AWS Problem You are tasked with writing a new program for your company that keeps track of the customer’s information and his or her current bill. The company wants the name, address, phone number, and balance to be stored for each customer. This program will demonstrate the following: How to use a class to organize data How to use methods to access the data of a class How to create objects from a class Solving the Problem Step...

  • Python 3 Problem: I hope you can help with this please answer the problem using python...

    Python 3 Problem: I hope you can help with this please answer the problem using python 3. Thanks! Code the program below . The program must contain and use a main function that is called inside of: If __name__ == “__main__”: Create the abstract base class Vehicle with the following attributes: Variables Methods Manufacturer Model Wheels TypeOfVehicle Seats printDetails() - ABC checkInfo(**kwargs) The methods with ABC next to them should be abstracted and overloaded in the child class Create three...

  • For written problems or problems where you are asked to provide an explaination you can submit...

    For written problems or problems where you are asked to provide an explaination you can submit your answers in a separate text file or you can just include them within your programs using Python comments. For problems requiring other written components (ie. structure chart), provide a pdf scan of the page(s). For each problem that requires coding, you must: Write a Python program Test, debug, and execute the Python program Save your program in a .py file and submit your...

  • Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters...

    Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters long encryptedPassword : String key int Must be between 1 and 10(inclusive) accountId - A unique integer that identifies each account nextIDNum – a static int that starts at 1000 and is used to generate the accountID no other instance variables needed. Default constructor – set all instance variables to a default value. Parameterized constructor Takes in clearPassword, key. Calls encrypt method to create...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT