V22.0002 - ASSIGNMENT 1
Write a program that computes the difference between two time
readings. The times are read into the program as 6-digit integers:
hhmmss, where hh stands for hour, mm
minutes and ss seconds. The difference should be displayed in
the same format. The difference can be both positive and negative. You
can assume, for now, that the inputs are correct (that is, you are not
going to have more than 59 seconds or more than 59 minutes).
Enter first 6-digit time: 23245
Enter second 6-digit time: 32815
Time difference: 5530
Enter first 6-digit time: 123245
Enter second 6-digit time: 112955
Time difference: -10250
Notes and Hints:
- The times expressed as a 6-digit integer can be larger than the
maximum size of a variable declared as integer, so you
will have to use a different data type (see page 87 of your book).
- The best way to compute the difference is to:
- Isolate the diferent parts of each time: hours, minutes and
seconds (MOD and DIV, hint, hint, hint).
- Compute the time in terms of seconds (1 hour = 3600 seconds, 1
minute = 60 seconds).
- Compute the difference in seconds.
- Convert the above number into hours, minutes and seconds
(again MOD and DIV, but with a different base,
hint, hint, hint).
- Build the new 6-digit integer.