Description
Submit a file called Assignment3.zip which contains:
• MaxInt.java
• Fraction.java
• Seconds.java
• Seconds2.java
Additional marking scheme:
-5 for any of the following:
• Compiler gives a warning.
• Constants are not used where appropriate. Constanst MUST be defined and used in 3 of the questions.
• Constants are incorrectly formatted
-20 if casting is not used in question 2.
QUESTION 1
Write a program called MaxInt.java which first defines two int constants. They contain the largest/smallest possible int values. Print their values. Then, add 1 to the largest value and subtract 1 from the smallest value. Print the results. Don’t just output 4 numbers. Include a short description for each one.
QUESTION 2
Write a program called Fraction.java which requests the user to enter a numerator and denominator for a fraction. Both are int’s. Use casting to display the fraction as a double.
QUESTION 3
PP2.8 on p. 109. Call the program Seconds.java.
Write a program that reads values representing a time duration in hours, minutes, and seconds and then prints the equivalent total number of seconds. (For example, 1 hour, 28 minutes, and 42 seconds is equivalent to 5322 seconds.)
QUESTION 4
PP 2.9 on p. 109. Call the program Seconds2.java.
Create a version of the previous project that reverses the computation. That is, read a value representing a number of seconds, then print the equivalent amount of time as a combination of hours, minutes, and seconds. (For example, 9999 seconds is 2 hours, 46 minutes, and 39 seconds.)