The most common cause of errors in computer systems is when users
type incorrect data. This program tries to handle bad data by
rejecting hours greater
than 23 and minutes greater
than 59. Error handling is generally performed by using if... commands to perform
a range-check, to see
that values are in the expected range.
This program should also check that the time ha:ma is actually earlier than
hb:mb.
We might be inclined to write the following:
if( ha
> hb || ma > mb)
{ output("The first time should be earlier
than the second"); }
But this isn't really correct. For example, the following
times are valid:
10:30 is earlier than 11:15,
even though 30 > 15.
8:15 is earlier than 8:45, even though 8 is not
smaller than 8.
The correct validity check is more complicated that shown above.