PROGRAM TimeHack;

{Programmer:	Gregory A. Perkins
				CS 65
 Due:			9/13/96}
{This program accepts two times given in 24-hour format from the user
	then calculates the amount of difference(time elapsed) between the
	two times and then displays the results on the screen}

VAR Hours1, Hours2, Mins1, Mins2, ElapsedHours, ElapsedMins: INTEGER;

BEGIN

{Introduction}
WRITELN('Hello, I am the time wizard!');
WRITELN;

{Explanation of program to user}
WRITELN('Please enter two separate times, and I will tell');
WRITELN('you the amount of time elapsed between the two times.');
WRITELN('All times must be given in the 24-hour clock format -- e.g. 4:30 p.m.= 1630.');
WRITELN;

{Get first time from user}
WRITELN('Beginning with the greater time, enter the hours,');
WRITELN('then enter the minutes.');
READLN(Hours1, Mins1);

{Get second time from user}
WRITELN('Now enter the hours, then enter the minutes, of');
WRITELN('the lesser time.');
READLN(Hours2, Mins2);

{Test value of minutes to ensure that a negative time is not given}
IF Mins1 < Mins2 THEN
	BEGIN
	Hours1 := Hours1 - 1;{Borrow an hour to give to minutes}
	Mins1 := Mins1 + 60;{Transfer of hour to minutes to ensure that negative time is not given}
	END;

{Determine amount of elapsed time}
ElapsedHours := Hours1 - Hours2;
ElapsedMins := Mins1 - Mins2;

{Display the amount of time elapsed}
WRITELN('The elapsed time is:');
WRITELN('              ',ElapsedHours,' hours and');
WRITELN('              ',ElapsedMins,' minutes.');
END.