Pascal help please

Soldato
Joined
5 May 2004
Posts
4,462
Location
Northern Ireland
Hi

Been working on this all day and I can seem to get past a mental block. Is there a way to get the program to write two sets of details as detailed on the output section based on what the user types in within the input section?

Code:
Program bookingflights;

{This program requests information via user input regarding the number of people wanting flights to London}

Const
Adultfare = 104.40; {The price of one adult ticket}
Childfare = 65.50; {The price of one child's ticket}
Baggagefee = 4.50; {Baggage handler's fee for each passenger travelling}
Airporttax = 13; {Tax charged on the total fares - 13%}

Var
Numofbookings: Integer; {Number of bookings in one session - current number of times round loop}
IterationNum: Integer;
Customername: String[20]; {Name of customer limited to 20 chars}
Numadult: Integer; {Number of adults, entered by keyboard}
Numchildren: Integer; {Number of children, entered by keyboard}
Numofpass: Integer; {Total number of passengers}
Totaladultfares: Real; {Total price for adult fares}
Totalchildfares: Real; {Total price for childrens' fares}
Totalfares: Real; {Total price for both sets of fares combined}
Tax: Real; {Tax added onto fares}
Totalbaggagefee: Real; {Total baggage fees}
Totalcosts: Real; {Total cost of fares, tax, and baggage}
Results: Text; {Outputing the results to a .dat file}


Begin
{Input section - via keyboard}
IterationNum:=1;
writeln('Please enter the number of bookings you wish to make in one session.');
ReadLn(Numofbookings);

{calculate the bookings}
While IterationNum <= Numofbookings Do
Begin
writeln('Please enter the customers name.');
ReadLn(Customername);
writeln('Please enter the number of adults.');
ReadLn(Numadult);
writeln('Please enter the number of children.');
ReadLn(Numchildren);
IterationNum:=IterationNum + 1 
End;


{Calculations}
If Numofbookings <= IterationNum Then
Begin
Numofpass:= Numadult+Numchildren;
Totaladultfares:= Numadult*Adultfare;
Totalchildfares:= Numchildren*Childfare;
Totalfares:= Totaladultfares+Totalchildfares;
Tax:= Totalfares*Airporttax/100;
Totalbaggagefee:= Numofpass*Baggagefee;
Totalcosts:= Totalfares+Tax+Totalbaggagefee;
End; 

{Output to a .dat file}
assign(results,'bookings.dat');
rewrite(results);
writeln(results,Customername);
writeln(results,'The total charge for adult fares = £',Totaladultfares:2:2);
writeln(results,'The total charge for children fares = £',Totalchildfares:2:2);
writeln(results,'The total charge for fares to London = £',Totalfares:2:2);
writeln(results,'Airport tax is chargerd @13% = £',Tax:2:2);
writeln(results,'The total baggage handling charges = £',Totalbaggagefee:2:2);
writeln(results,'Total Costs = £',Totalcosts:2:2);
writeln(results,'');
close(results);
End.

If anyone could give me even a few pointers it would be great. Feel free to add me to msn (via trust) if you want too :)

Thanks

Blackvault
 
Back
Top Bottom