CSC103 Lab exercise 2

Part 1



As most of us know, there are 24 hours in a day, and 60 minutes in an hour.. You are to write a C++ program which will prompt for a time period in minutes and then compute the number of days, hours, and minutes in that time period. Save the program as getsec.cpp.

Organize your program as:



1. Prompt the user for the time period Period and read the value the user types.



2. Use the same methods used in class to compute the number of coins in change to compute the Days, Hours, Minutes.



3. Output the values you computed and the value that was inputted in a complete sentence.



Try the program for several values.



For Period = 1450, answer is 1 Days, 0 Hours and 10 Minutes.

For Period = 4765, answer is 3 Days, 4 Hours and 25 Minutes.



Part 2



You are now to write a program which prompts for two times and computes the number of Days, Hours and Minutes between them. Each of the times will be in Days, Minutes and Hours. Please assume that the second time is later the first time. You will use the code you developed in Part 1 in this program. Save the program as differ.cpp.

An algorithm for this program is:



1. Prompt for the first time as Day1, Hour1, Minute1 and read values.



2. Prompt for the second time as Day2, Hour2, Minute2 and read values.



3. Compute the total number of minutes, TotalMinute1, in the first time and the total number of minutes, TotalMinute2, in the second time..



4. Compute the difference between the times, Difference.



5. Use the code from part 1 to determine the number of days, minutes, and seconds in the difference.



6. Write the values computed in step 5 in a readable format.



DISK AND LISTING OF BOTH PROGRAMS ARE DUE AT START OF LAB ON SEPTEMBER 22.