(* Teresa Tong F.4AS [30] March,2002 *)
(* Write a program with a procedure RoomCharge to compute
the total charge for a hospital room *)
program HospitalRoom;
uses wincrt;
var day:integer;
room:char;
sum:integer;
procedure RoomCharge(day:integer;
room:char;
var total:integer);
begin
If room='A'
then total:=1000*day;
If room='B'
then total:=500*day;
If room='C'
then total:=100*day;
end;
begin
sum:=0;
writeln(' Room type code Daily rate($)');
writeln(' first class A 1000');
writeln(' second class B 500');
writeln(' ward C 100');
writeln;
writeln('What room would you like ( A, B or C )? ');
readln(room);
If ( room='A' ) or ( room='B' ) or ( room='C' )
then begin
Writeln('How many days would you like to stay? ');
readln(day);
RoomCharge( day, room, sum);
writeln('Total charge is $',sum);
end
else begin
repeat
writeln('No such room. Please enter again. ' );
readln(room);
until ( room='A' ) or ( room='B' ) or ( room='C' );
Writeln('How many days would you like to stay? ');
readln(day);
RoomCharge( day, room, sum);
writeln('Total charge is $',sum);
end
end.
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Output:
1) Room type code Daily rate($)
first class A 1000
second class B 500
ward C 100
What room would you like ( A, B or C)?
A
how many days would you like to stay?
10
Total charge is $10000
2) Room type code Daily rate($)
first class A 1000
second class B 500
ward C 100
What room would you like ( A, B or C)?
D
No such room. Please enter again.
C
How many days would you like to stay?
5
Total charge is $500
               (
geocities.com/ttt_7_ttt)