Question: JAVA: Example program Section 2.4: int hour = 11; int minute = 59; System.out.print(The current time is ); System.out.print(hour); System.out.print(:); System.out.print(minute); System.out.println(.); The output of

JAVA:

Example program Section 2.4:

int hour = 11;

int minute = 59;

System.out.print("The current time is ");

System.out.print(hour);

System.out.print(":");

System.out.print(minute);

System.out.println(".");

The output of this program is: The current time is 11:59.

QUESTION:

1. Create a new program called Time.java. From now on, we wont remind you to start with a small, working program, but you should. 2. Following the example program in Section 2.4, create variables named hour, minute, and second. Assign values that are roughly the current time. Use a 24-hour clock so that at 2pm the value of hour is 14. 3. Make the program calculate and display the number of seconds since midnight. 4. Calculate and display the number of seconds remaining in the day. 5. Calculate and display the percentage of the day that has passed. You might run into problems when computing percentages with integers, so consider using oating-point. 6. Change the values of hour, minute, and second to reect the current time. Then write code to compute the elapsed time since you started working on this exercise.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!