Write a driver class that has the main method this main


Test 1

You are permitted the use of pre-written notes, previous labs and the textbook. You are NOT permitted the help of the Lab TA or the Internet. Any cheating will result in a report Academic Integrity Violation and an ‘F' in the course.

Document your code with inline comments and javadoc comments. This is a majot portion of your grade.

Read this entire document before starting to write code.

Write and test a Java project that satisfies the following requirements:

Create a measurement converter project that can convert between grams, ounces, pounds and kilograms.

The constants for conversion are:

1 ounce = 28.35 grams
16 ounces = 1 pound
1 kg = 1000 grams

Write a class definition file named WeightConverter that has these fields:

weightInOunces
weightInPounds
weightInGrams
weightInKiloGrams

The class also needs the three constant fields for the conversions as listed above.

Write the following methods:

Two constructor methods:

The default constructor sets all the field values to zero except the constant. The constant is set using the conversion given above.

The overloaded constructor accepts a value for the weight of an item in pounds and calculates the values for the remaining three fields.

Write four set( ) methods that allows the user to change any measure (setOunces, setPounds, setGrams, setKiloGrams) The set methods must ensure all the fields are consistent.

Write four get( ) methods. One get method for each of the four fields (not including the constants.

Write a driver class that has the main( ) method. This main method should provide the following utility:

Create an instance of the WeightConverter class using the default values.

Write a loop that allows the user to reset any of the measures. Ask the user to enter which measure to change, read in the value and call the appropriate set method. Then print the value of each of the four fields. This process continues until the user indicates he/she wants to quit.

Once the loop exits, print a Goodbye message.

Solution Preview :

Prepared by a verified Expert
Programming Languages: Write a driver class that has the main method this main
Reference No:- TGS01723992

Now Priced at $40 (50% Discount)

Recommended (90%)

Rated (4.3/5)