Programming Assignment 2
CS 12300
Programming I: Java
Spring, 2021

This assignment is due Tuesday, February 9.

This assignment makes use of the files contained in this zip file.

This assignment uses the material in Chapter 2, Chapter 3, Section 1.3, and Section 1.4.

For this assignment you will write four short programs that do some unit conversions. In the zip file there are outlines of four programs that you need to complete, Hw2_Part1.java, Hw2_Part2.java, Hw2_Part3.java, and Hw2_Part4.java.

The first program converts a combination of feet and inches to centimeters. Your code needs to use the fact that there are 2.54 centimeters to an inch. Your program should read both the number of feet and the number of inches as an int value and it should compute the centimeter value as a double.

The second program converts a number of inches into the equivalent number of feet and inches. Your code needs to use both the integer quotient operator (the / symbol) and the integer remainder operator (the % symbol). Read Section 3.8 and Section 1.4.4.

The third program converts a number of ounces into the equivalent number of gallons, quarts, cups and ounces (all of these values are integers). Your code will once again need to use both the integer quotient and the integer remainder operators, but this time your code will need to use these operators several times.

The fourth program converts the combination of a number of gallons, quarts and ounces into the equivalent number of liters. The number of gallons, quarts and ounces should all be int values, but the value in liters should be a double. When your program prints the value of liters it should print only four decimal places to the right of the decimal point. Java normally will print a double with about 16 decimal places to the right of the decimal point. Read Section 3.5 or Java printf() Method Quick Reference to learn how to change how many decimal places get printed.

In the zip file there are a number of screenshots of the four programs being used. Your four program should act exactly like what is shown in the screenshots. Use the screenshots to check that your programs produce correct results.

Turn in a zip file called CS123Hw2Surname.zip (where Surname is your last name) containing (just) your versions of the four files Hw2_Part1.java, Hw2_Part2.java, Hw2_Part3.java, and Hw2_Part4.java. Be sure to put your name in all of your files. (Please don't put all the screenshots in your zip file.)

This assignment is due Tuesday, February 9.