Getting Started:
- Fork this repository to your GitHub account.
- Clone the forked repository locally to your machine.
- Create a new branch named Feature01 to work on this exercise.
Objective: This exercise aims to (1) utilize arithmetic operators and (2) introduce the concept of compound entities, such as the time of day, represented by multiple values.
Instructions:
- Create a new Java file in the src directory named
Time.java
. Start with a small, working program as a foundation. - Following the example program in Section 2.4 of your book, define variables named
hour
,minute
, andsecond
. Assign values that approximate the current time. Use a 24-hour clock (e.g., sethour
to 14 for 2:00 PM). - Implement the program to calculate and display the number of seconds since midnight.
- Extend the program to calculate and display the number of seconds remaining in the day.
- Further enhance the program to calculate and display the percentage of the day that has passed. Be cautious when dealing with percentages using integers; consider using floating-point numbers.
- Modify the values of
hour
,minute
, andsecond
to reflect the current time. Then, write code to compute the elapsed time since you started working on this exercise.
Hint: Consider using additional variables to hold values during computation. Variables used in computation but not displayed are sometimes referred to as "intermediate" or "temporary" variables.
Just as you did in the first lab (Reference the Lab video in your Week 1 module):
- create a Feature01 branch of your code if you haven't already.
- Commit your working code to your local copy/Feature01 branch
- Push it to your Remote/origin branch (i.e. GitHub: Feature01 -> origin/Feature01)
- Then issue a Pull request to my instructor repo
- Make sure to COPY the Pull request URL and submit it for the lab/assignment in Canvas.
"Time is what we want most, but what we use worst." - William Penn