| | | 4.5 Enter a PASCAL program |
4.5 Enter a PASCAL program
Using the pico
text editor create a file called trip.pas
containing the following PASCAL program.
Do not worry about minor typing errors. Leave a
minor error in your file so that you can see an error message
when compiling the program in
Lab 4.6: "Pascal program -- compile and run".
Use the file name trip.pas for this program.
The program is also avaliable at:
ftp://lt.tucson.az.us/pub/cis135/trip.pas.
program trip(input,output);
var
distance,speed,time,galcost,
mpg,galused,totalcost:real;
begin
writeln('* Compute trip time and cost. *');
writeln;
write('Trip distance? ');
read(distance);
write('Average speed? ');
read(speed);
write('Miles per gallon? ');
read(mpg);
write('Cost per gallon? ');
read(galcost);
writeln;
writeln('Distance = ',distance:8:2,' miles');
writeln('Average speed = ',speed:8:2,' miles');
time:=distance/speed;
writeln('Time of trip = ',time:8:2,' hours');
writeln;
writeln('Mileage rate = ',mpg:8:2,' miles/gal');
writeln('Dollars per gallon = ',galcost:8:2,' dollars');
galused:=distance/mpg;
totalcost:=galused*galcost;
writeln('Estimated trip cost = ',totalcost:8:2,
' dollars');
end.
Print a copy of the file on the system printer.
Use the command:
lpr trip.pas
Label it with
Your-Name
Lab 4.5: Pascal Source
TABER CIS135
Place the lab in the instructor hand-in box
in BUS R6E, the "terminal room".
Instructor: ltaber@pima.edu ** My new Home at GeoApps in Tucson ** The Pima College Site ** The Mad Dr. G.'s home page on phred.
| | | 4.5 Enter a PASCAL program |