Question: The program must accept times in the following form < hours : minutes : seconds > where each < hours >, < minutes >, <

The program must accept times in the following form< hours : minutes : seconds > where each< hours >, < minutes >, < seconds > and are integers and the spaces around the colon are optional.

In order to use a Scanner, we need to specify that : is a delimiter character (a character that indicates the end of an expression and the beginning of another similar to a period between sentences).

When creating the Scanner the following code is required: new Scanner(System.in).useDelimiter("\\s*:\\s*");

The name of the class that contains the main must be TimeInterpreter.

Output will generally follow the same input format where days, hours, minutes, and seconds must be followed by a colon (:); see sample output for examples.

All times will be output without spaces (or other whitespace).

Negative Times. If a specified time is negative, it should be printed with a single leading negative. For example, 0:-2:-34: is output as -2:34:.

Simplification. Times must be simplified before printed. For example, 12:2:-34: is simplified and output as 12:1:26.

Output Brevity. For input time 0:2:34:, the corresponding output should not list the number of hours (since there are none): 2:34:.

A single output print statement will be allowed in the final solution code. That is, a proper solution will construct a String object and output it at the end of the program.

You must define and use constants representing the number of seconds per minute, hour, and day.

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!