Due date: Wednesday, February 5, 2020.
Objective: To use variables in Java, arithmetic expressions, and input / output statements.
Ex. 1. Time in seconds.
In this project, we will input a time value expressed in seconds and we will display the answer in a format showing a number of hours, of minutes, and of seconds. For example, if the number of seconds is 5000, then the program will output 1h, 23m, 20s, because 1*3600 + 23*60 + 20 = 5000.
Create a Java project in Eclipse and call it hw3. Create a class in this project called TimeDisplay and containing the main method. Write your name, course, semester, and homework number at the top as a comment.
Declare four int variables for the input in seconds, and the computed time in hours, minutes, and seconds. Repeat the lab steps to add a Scanner to your program, then ask the user for an input value in seconds. Use the method nextInt() to input this value.
Next, compute the value of the seconds by using the total number of seconds %60. Then divide the total number of seconds by 60 and store it in the minutes variable. After that, compute the hours as the minutes divided by 60, and the final value of the minutes as the current value of the minutes %60.
Finally, output the three values in a way that makes it clear which value is the hours, which the minutes, and which the seconds.
Turn in: the lab and homework .java files: Convert.java and TimeDisplay.java. Upload them to Canvas in Assignments - Homework 3.