Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise 3 The point of this exercise is to ( 1 ) use some of the arithmetic operators, and ( 2 ) start thinking about
Exercise
The point of this exercise is to use some of the arithmetic operators, and start thinking about compound entities like time of day that are represented with multiple values.
Create a new program called Time.java. From now on we wont remind you to start with a small, working program, but you should.
Following the example program in Section create variables named hour, minute, and second. Assign values that are roughly the current time. Use a hour clock so that at : PM the value of hour is
Make the program calculate and display the number of seconds since midnight.
Calculate and display the number of seconds remaining in the day.
Calculate and display the percentage of the day that has passed. You might run into problems when computing percentages with integers, so consider using floatingpoint.
Change the values of hour, minute, and second to reflect the current time. Then write code to compute the elapsed time since you started working on this exercise.
Hint: You might want to use additional variables to hold values during the computation. Variables that are used in a computation but never displayed are sometimes called intermediate or temporary variables.
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