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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started