I am working on a school project, I need to do a keystroke to simulate
filling car with petrol. There is two program I have done below but none
of them work. I use Borland developer studio 2006 (Delphi Pascal) and
does anyone know how to clear the screen in the console please. Can
anyone want help me or tell me what is wrong with my program please.
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
start_time,stop_time,total_time:real;
key:string;
procedure first_time;
begin
start_time := time;
end;
procedure secound_time;
begin
stop_time := time;
end;
begin
writeln('Press F to get start time');
readln(key);
writeln('Press S to get stop time');
readln(key);
writeln('Press A to get total time');
readln(key);
readln;
if key = 'f' then
(first_time) ;
if key = 's' then
(secound_time);
if key ='a' then
total_time := stop_time - start_time;
writeln(total_time);
readln;
end.
program Project2;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
total_time:word;
start_time,start_min,start_sec,start_hour:word;
stop_time,stop_hour,stop_min,stop_sec:word;
hour,min,sec,msec:word;
key:string;
begin
writeln('Press F to get start time');
readln(key);
writeln('Press S to get stop time');
readln(key);
writeln('Press A to get total time');
readln(key);
if key = 'f' then
begin
DecodeTime( time, hour, min, sec, msec );
start_hour:= hour *3600;
start_min:= min*60 ;
start_sec:=sec;
start_time:= start_hour + start_min + start_sec ;
end;
if key = 's' then
begin
DecodeTime( time, hour, min, sec, msec );
stop_hour:= hour *3600;
stop_min:= min*60 ;
stop_sec:=sec;
stop_time:= stop_hour + stop_min + stop_sec ;
end;
if key = 'a' then
total_time := stop_time - start_time;
writeln(total_time);
readln;
end.