Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

Discuss the techniques of sales forecasting.

Answered: 1 week ago

Question

Write short notes on Marketing mix.

Answered: 1 week ago

Question

=+8. Why is productivity important?

Answered: 1 week ago

Question

=+ 9. What is inflation and what causes it?

Answered: 1 week ago