this is a program written in pascal language to
l got stocked along the way. please a need a way out. Thank you.
akintobi 0 Newbie Poster
This attachment is potentially unsafe to open. It may be an executable that is capable of making changes to your file system, or it may require specific software to open. Use caution and only open this attachment if you are comfortable working with msword files.
Dani 4,329 The Queen of DaniWeb Administrator Featured Poster Premium Member
Here is the code for those of you who don't want to download the attached file:
Program Airline(input, output);
Uses CRT;
Type
PassRec=Record
Name:string[38];
Address:string[38];
Telephone_number: Integer;
Date_of_birth:string;
End;
Passengers=file of passRec;
Var
DAccess:Passengers;
Seats:Array[1..40] of string;
Seat_code:string;
Picket_Seats:string;
seats_number:string;
ticket_number:string;
i:integer;
Option:char;
Procedure Main_menu;
Begin
clrscr;
Gotoxy(15,5); Write('Main menu');
Gotoxy(10,7); Write(' 1- Booking');
Gotoxy(10,9); Write(' 2- Amending');
Gotoxy(10,11); Write(' 3- Deleting record');
Gotoxy(10,13); Write(' 4- Confirming booking');
Gotoxy(10,15); Write(' 5- Cancelling');
Gotoxy(10,17); Write(' 6- Issuing your ticket');
Gotoxy(10,19); Write(' 7- Displaying your seat status');
Gotoxy(10,21); Write(' 8- Exiting the program');
Gotoxy(8,23); Writeln('Please select option 1, 2, 3, 4, 5, 6, 7 or 8');
Option:=upcase(Readkey);
End;
Procedure booking;
Var
Choosed_seat:string;
Begin
clrscr;
gotoxy(7,5); write('There are four (4) kinds of seats, which are: ten (10) ');
gotoxy(7,7); write('business seats coded Bs, ten (10) left windom seats coded Ls,');
gotoxy(7,9); write('ten (10) right window seats coded Rs and ten (10) middle seats');
gotoxy(7,11); write('coded Ms.');
gotoxy(7,13); write('All the seats are followed a number from 1 to 10 as bellow.');
gotoxy(5,17); write('Bs1');
gotoxy(5,19); write('Bs2');
gotoxy(10,17); write('Bs3');
gotoxy(10,19); write('Bs4');
gotoxy(15,16); write('Bs5');
gotoxy(15,18); write('Bs6');
gotoxy(15,20); write('Bs7');
gotoxy(20,16); write('Bs8');
gotoxy(20,18); write('Bs9');
gotoxy(20,20); write('Bs10');
gotoxy(26,16); write('Rs1');
gotoxy(31,16); write('Rs2');
gotoxy(36,16); write('Rs3');
gotoxy(41,16); write('Rs4');
gotoxy(46,16); write('Rs5');
gotoxy(51,16); write('Rs6');
gotoxy(56,16); write('Rs7');
gotoxy(61,16); write('Rs8');
gotoxy(66,16); write('Rs9');
gotoxy(71,16); write('Rs10');
gotoxy(26,18); write('Ms1');
gotoxy(31,18); write('Ms2');
gotoxy(36,18); write('Ms3');
gotoxy(41,18); write('Ms4');
gotoxy(46,18); write('Ms5');
gotoxy(51,18); write('Ms6');
gotoxy(56,18); write('Ms7');
gotoxy(61,18); write('Ms8');
gotoxy(66,18); write('Ms9');
gotoxy(71,18); write('Ms10');
gotoxy(26,20); write('Ls1');
gotoxy(31,20); write('Ls2');
gotoxy(36,20); write('Ls3');
gotoxy(41,20); write('Ls4');
gotoxy(46,20); write('Ls5');
gotoxy(51,20); write('Ls6');
gotoxy(56,20); write('Ls7');
gotoxy(61,20); write('Ls8');
gotoxy(66,20); write('Ls9');
gotoxy(71,20); write('Ls10');
gotoxy(7,23); writeln('Please enter the seat code you would like to choose');
Readln(choosed_seat);
end;
Procedure Adding_Record;
Var
Newpass:PassRec;
Count:integer;
Begin
Assign(DAccess,'Datafile.DAT');
Rewrite(DAccess);
Count:=1;
While count<=40 do
Begin
With Newpass do
Begin
Clrscr;
Writeln('Please enter your name');
Readln(Newpass.name);
Writeln('Please your date of birth');
Readln(Newpass.date_of_birth);
Writeln('Please enter your telephone number');
Readln(Newpass.telephone_number);
Writeln('Please enter your address');
Readln(Newpass.address);
End;
Count:=count+1;
Write(DAccess,Newpass);
End
End;
Procedure Amending;
Var
Found:Boolean;
Ticket_number:Passrec;
ticket:integer;
Count:integer;
Ticketnumbertofind:integer;
Begin
clrscr;
Assign(DAccess,'Datafile.DAT');
Reset(DAccess);
Writeln('Please enter your ticket number to find');
Readln(Ticketnumbertofind);
Found:=false;
While not found do
Begin
Seek(DAccess,ticketnumbertofind);
If not EOF then
Read(DAccess,ticket_number);
If(Ticket=Ticketnumbertofind) then
Found:=true
else writeln('Ticket not found');
End;
If found then
with Ticket_number do
Begin
Writeln('Your name is:',name);
Writeln('Your address is :',address);
Writeln('Your date of birth is : ',date_of_birth);
Writeln('Your telephone number is : ',telephone_number);
Writeln('Press enter key to rewrite your records');
Readkey;
Write(DAccess,ticket_number);
End
End;
Procedure Deleting_Record;
Var
Found:Boolean;
Ticket_number:PassRec;
Ticketnumbertofind:integer;
ticket:integer;
option:char;
Begin
clrscr;
Assign(DAccess,'Datafile.DAT');
Reset(DAccess);
Writeln('Please enter your ticket number to find');
Readln(Ticketnumbertofind);
Found:=false;
While not found do
Begin
Seek(DAccess,Ticketnumbertofind);
If not EOF then
Read(DAccess,Ticket_number);
If Ticket=Ticketnumbertofind then
Found:=true
else writeln('Ticket not found');
End;
If found then
with Ticket_number do
Begin
Writeln('Your name is:',name);
Writeln('Your address is : ',address);
Writeln('Your date of birth is : ',date_of_birth);
Writeln('Your telephone number is : ',telephone_number);
Writeln('Do you want to delete your record ? Y/N ');
option:=upcase(Readkey);
If (option='Y') then
write('Your records are deleted');
delay(2000);
If(option='N') then
Write('Tkanks for keeping your records');
delay(2000);
End
End;
Procedure Confirming_booking;
Var
Found:Boolean;
Ticket_number:PassRec;
Ticketnumbertofind:integer;
Ticket:integer;
option:char;
Begin
clrscr;
Assign(DAccess,'Datafile.DAT');
Reset(DAccess);
Writeln('Please enter your ticket number');
Readln(Ticketnumbertofind);
Found:=false;
While not found do
Begin
Seek(DAccess,Ticketnumbertofind);
If not EOF then
Read(DAccess,Ticket_number);
If Ticket=Ticketnumbertofind then
Found:=true
else writeln('Ticket not found');
End;
If found then
with Ticket_number do
Begin
Writeln('Your name is:',name);
Writeln('Your address is : ',address);
Writeln('Your date of birth is : ',date_of_birth);
Writeln('Your telephone number is : ',telephone_number);
Writeln('Do you want to change your seat status ? Y/N ');
option:=upcase(Readkey);
If(option='Y') then booking
else Write('Thanks for keeping your seat');
End
End;
Procedure Cancelling;
Var
Found:Boolean;
Ticket_number:PassRec;
Ticketnumbertofind:integer;
Ticket:integer;
option:char;
Begin
Assign(DAccess,'Datafile.DAT');
Reset(DAccess);
Writeln('Please enter your ticket number');
Readln(Ticketnumbertofind);
Found:=false;
While not found do
Begin
Seek(DAccess,Ticketnumbertofind);
If not EOF then
Read(DAccess,Ticket_number);
If Ticket=Ticketnumbertofind then
Found:=true
else writeln('Ticket not found');
End;
If found then
with Ticket_number do
Begin
Writeln('Your name is:',name);
Writeln('Your address is : ',address);
Writeln('Your date of birth is : ',date_of_birth);
Writeln('Your telephone number is : ',telephone_number);
Writeln('Do you want to cancel your booking ? Y/N');
option:=upcase(readkey);
If(option='Y') then
write('Your booking is cancelled')
else Write('Thanks for keeping your booking');
End
End;
Procedure Issuing_ticket;
Var
Found:Boolean;
Ticket_number:PassRec;
Ticketnumbertofind:integer;
Ticket:integer;
Option:char;
Begin
Assign(DAccess,'Datafile.DAT');
Reset(DAccess);
Writeln('Please enter your ticket number');
Readln(Ticketnumbertofind);
Found:=false;
While not found do
Begin
Seek(DAccess,Ticketnumbertofind);
If not EOF then
Read(DAccess,Ticket_number);
If Ticket=Ticketnumbertofind then
Found:=true
else writeln('Ticket not found');
End;
If found then
with Ticket_number do
Begin
clrscr;
{ Writeln('We repeat your ticket number is : ',Ticket_number);}
Writeln('Your name is:',name);
Writeln('Your address is : ',address);
Writeln('Your date of birth is : ',date_of_birth);
Writeln('Your telephone number is : ',telephone_number);
Delay(3000);
End
End;
Procedure Displaying_seat_status;
Var
Found:Boolean;
Ticket_number:PassRec;
Ticket:integer;
Ticketnumbertofind:integer;
Choosed_seat:string;
Begin
Assign(DAccess,'Datafile.DAT');
Reset(DAccess);
Writeln('Please enter your ticket number');
Readln(Ticketnumbertofind);
Found:=false;
While not found do
Begin
Seek(DAccess,Ticketnumbertofind);
If not EOF then
Read(DAccess,Ticket_number);
If Ticket=Ticketnumbertofind then
Found:=true
else writeln('Ticket not found');
End;
If found then
with Ticket_number do
Begin
clrscr;
Writeln('Your seat is ', choosed_seat);
Writeln('Your name is:',name);
Writeln('Your address is : ',address);
Writeln('Your date of birth is : ',date_of_birth);
Writeln('Your telephone number is : ',telephone_number);
Delay(3000);
End
End;
{.... Main program lines....}
BEGIN
Repeat
Main_menu;
case option of
'1': begin
Booking;
Adding_record
end;
'2': begin
Amending
end;
'3': begin
Deleting_record
end;
'4': begin
Confirming_booking
end;
'5': begin
Cancelling
end;
'6': begin
Issuing_ticket
end;
'7': begin
Displaying_seat_status
end;
'8': begin
clrscr;
Write('thank you for using the progrm and good bye');
Delay(2000)
end;
else
begin
clrscr;
Write('invalid data typped')
end;
end;
delay(2000);
until option='8';
clrscr
End.
akintobi, can you please explain to us what the program does versus what you want it to do, what about it you're having a problem with, etc.
radu84 4 Junior Poster
as csgal said upper on this page, give us more details, and also provide us errors and the line where error occured
best regards,
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.