ITCS 1213

ITCS 1213

ITCS 1213

Test 1 

This grade will be calculated as 25% of the lecture 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: 




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.

You will be graded on:

The code must compile.

The code must be well documented. Document each method and use the conventions for naming fields, constants, local variables, constants and class names as well as javadoc comments. 

The code must give correct results in the output. 

When done: 

• Submit the two .java source code files to Moodle. Be sure your submissions have been uploaded correctly. This is your responsibility.
• Give this requirements sheet back to your Lab TA. If you do not give the sheet back you will earn a zero on this test.
• Shut down the computer.
Powered by