Question: Problem description Design and implement program in C++ that inputs an integer that represents a length of time in seconds. The program should then output

Problem description

Design and implement program in C++ that inputs an integer that represents a length of time in seconds. The program should then output the number of days, hours, minutes, and seconds that corresponds to that number of seconds.

For example, if the user inputs 50391 total seconds, then the program should output 13 hours, 59 minutes, and 51 seconds (see sample interaction).

Use constants for the number of seconds in a minute (60), the number of minutes in an hour (60), and the number of hours in a day (24). Declare the constants within your main function.

Input specification

The number of seconds will be a positive integer between 0 and 231-1 inclusive.

Output specification

Days, hours, minutes, and seconds are whole number values. Output formatting should be identical to that shown in the sample interaction below.

Sample interaction

Do not type the $ character - it represents your shell prompt!

$ clang++ $CXXFLAGS pa02b.cpp $ ./a.out Please enter the number of seconds: 50391 0 days, 13 hours, 59 minutes, 51 seconds $ ./a.out Please enter the number of seconds: 1631504859 18883 days, 3 hours, 47 minutes, 39 seconds. $

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 Programming Questions!