Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Topic Video
Question
In java
Project #1: Time Interpreter
Overview
Write a program that accepts a time from the keyboard and prints the times
form.
seconds and in simplified
Input
The program must accept times in the following form:
<hours> [space] <minutes> [space] <seconds>
where each <hours>, <minutes>, and <seconds> are integers and [space] represents the space
being
Prompt the user with the exact phrasing of the sample input / output shown below; note that the input
from the keyboard is depicted in green:
Enter the time in the form <hours minutes seconds>:
1 23
The time consists of 3723 seconds.
Simplified time: 1:2:3
Requirements
The name of the class that contains the main must be TimeInterpreter.
• While input uses spaces between the input numbers, the output format with days, hours, minutes,
and seconds should be delimited by colons; 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.
expand button
Transcribed Image Text:Project #1: Time Interpreter Overview Write a program that accepts a time from the keyboard and prints the times form. seconds and in simplified Input The program must accept times in the following form: <hours> [space] <minutes> [space] <seconds> where each <hours>, <minutes>, and <seconds> are integers and [space] represents the space being Prompt the user with the exact phrasing of the sample input / output shown below; note that the input from the keyboard is depicted in green: Enter the time in the form <hours minutes seconds>: 1 23 The time consists of 3723 seconds. Simplified time: 1:2:3 Requirements The name of the class that contains the main must be TimeInterpreter. • While input uses spaces between the input numbers, the output format with days, hours, minutes, and seconds should be delimited by colons; 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.
Sample Input / Output
Please use all of the following examples for test cases (your grader will), but do not limit your tests to
these input times. There is no need to represent time beyond days in your output.
Input Time
Expected Output Time
1 2 3
1:2:3
1 2 90
1:3:30
1 2 -90
1:0:30
48 0 0
2:0:0:0
0 0 0
0 2 -120
1 -300 2
-3:59:58
Recommendations
• Compute the number of seconds represented by the input and use the number of seconds for the
basis of your output; use a long for this quantity.
• Before coding, work out on paper the logic and computations for a given time.
Be thorough in your testing because it is an instructor's (or grader's) job to try and break your
code.
expand button
Transcribed Image Text:Sample Input / Output Please use all of the following examples for test cases (your grader will), but do not limit your tests to these input times. There is no need to represent time beyond days in your output. Input Time Expected Output Time 1 2 3 1:2:3 1 2 90 1:3:30 1 2 -90 1:0:30 48 0 0 2:0:0:0 0 0 0 0 2 -120 1 -300 2 -3:59:58 Recommendations • Compute the number of seconds represented by the input and use the number of seconds for the basis of your output; use a long for this quantity. • Before coding, work out on paper the logic and computations for a given time. Be thorough in your testing because it is an instructor's (or grader's) job to try and break your code.
Expert Solution
Check Mark
Step 1

Java code is giving below-

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education