Unit Conversions
Write a program that prompts the user for an integer which represents
some number of seconds. Your program should print out the number of
seconds, minutes, hours and days that the number of seconds represents.
Use integers for your calculations which will mean that your results
will truncate fractional amounts.
Expected Output
D:\mozilla>foo
Enter the number of seconds: 100000
100000 seconds = 1666 minute(s)
100000 seconds = 27 hour(s)
100000 seconds = 1 day(s)
Solution
Additional Challenge
Modify the program so that it prints out the number of days, hours and
minutes. So that an input of 90065 would return 1 day, 1 hour, 1 minute
and 5 seconds.
Return to Homepage Return to Programming Pages
Updated November 24, 2005. For comments and questions, send email to Vector.x64 @ gmail.com (without the spaces).