Create a NOTEPAD or PDF file that restates the problem in your own words, specif
ID: 3871638 • Letter: C
Question
Create a NOTEPAD or PDF file that restates the problem in your own words, specifies what input is needed from whomever is using the process, what output is expected, the step by step process (algorithm) to get the output from the input, and test data (input for which you know the expected output for each of the 3 problems given below. You should not write any actual C++ code.
Create a process to prompt the user to enter the number of seconds and determine the whole number of days, hours, minutes, and seconds corresponding to the entered number of seconds. For example if the number of seconds entered was 183945, then 2 days, 3 hours, 5 minutes and 45 seconds should be displayed. There are 86400 seconds in a day, 3600 seconds in an hour, and 60 seconds in a minute. Consider all values to be whole numbers
Explanation / Answer
Question states that:
n seconds are given, and convert those seconds into the format(days/hrs/min/sec).
Logic:
There can be three cases here:
Now we will apply the cases:
The formula for breaking down the seconds into equivalent minutes and seconds is:
If given seconds are n, then
Minutes=n/60
Seconds=n%60
For example: If user enters 4567, then by using the above formula,
Minutes=4567/60=77 minutes
Seconds=4567%60=37 seconds
Now the minutes are greater than 60, so we will split the minutes into equivalent hours and minutes. Formula is:
Hours=Mintues/60 that is 77/60=1 hours
Minutes=Minutes%60 that is 17 minutes.
Thus 4567 seconds=1 hour 17 mins 37 seconds
For example: if user enters 183945, then we will split the hours into days and hours, Formula is:
Days=Hours/24
Hours=Hours%24
Minutes=183945/60=3065
Seconds=183945%60=45
Hours=3065/60=51
Minutes=3065%60=5
Days=51/24=2
Hours=51%24=3
Thus 183945 seconds= 2Days 3 Hours 5 Minutes 45 Seconds
Algorithm:-
Purpose:- Given seconds=n, convert them into format (days/hours/minutes/seconds)
min=n/60
sec=n%60
hr = min/60
min = min%60
day=hr/24
hr=hr%24
Print the entered seconds into the converted format
ELSE apply following:-
min = n/60
sec = n%60
Print the entered seconds into the converted format
END IF
4.Stop