Question
Homework 3-2 - In Java Write a program that converts a total number of seconds to hours, minutes, and seconds. It should do the following:
Homework 3-2 - In Java
Write a program that converts a total number of seconds to hours, minutes, and seconds.
It should do the following:
-
Prompt the user for input
-
Read an integer from the keyboard
-
Calculate the result
-
Use printf to display the output
Your output must be of the format:
totalSeconds seconds = numHours hours, numMinutes minutes, and numSeconds seconds
For example:
If the user entered: 5000
Your program would output: 5000 seconds = 1 hours, 23 minutes, and 20 seconds
5000 seconds = 01h:23m:20s
Sample run would look like:
Enter the number of seconds: 5000
5000 seconds = 1 hours, 23 minutes, and 20 seconds
5000 seconds = 01h:23m:20s
Sample run would look like:
Enter the number of seconds: 3754
3754 seconds = 1 hours, 2 minutes, and 34 seconds
3754 seconds = 01h:02m:34s
Hint1: Use integer division
Hint2: Use the modulus operator
Please make sure to end each line of output with a newline.
Please note that your class should be named SecondsConverter.
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