Sunteți pe pagina 1din 21

Certificate

This is to certify that Siddharth Srivastava and


Vedansh of Class XII A1 has successfully completed his
computer project on topic ‘Airline Reservation System’
Prescribed by Mr Anik Pandey ,during academic session
2018-19 as per the guidelines issued by Central Board
Of Secondary Education.

Signature Signature
Computer Teacher External Examiner
Acknowledgement

we would like to express our


special thanks of gratitude to
our teacher Mr. Anik Pandey who
gave us this opportunity to do
this project on the topic Airline
Reservation System, which directed
us towards a lot of research and
we came to know about many
things that we are really
thankful for.

Secondly we would thank our


parents and friends who helped us
a lot in finalizing this project
within the limited time frame.
Contents

 Header Files Used


 Data Files Generated
 Working Description
 Coding
 Output Screens
 Bibliography
Header Files Used

iostream.h – for cin,cout


conio.h - for clrscr(),getch()
string.h - for string handling
process.h - for exit()
stdio.h - for standard I/O
operations
fstream.h - for file handling
Data Files Generated

Flight.dat- Stores flights data

Ticket.dat– Stores Tickets

Passengers.dat-Stores passenger
details
Working Description

This program is designed to book local


flight tickets.

User can enter departure and arrival


destination and if corresponding flights
are available, user id notified and flights
can be chosen through their number.

The User Menu is as follows:

1. Flight Database
2. Booking
3. Ticket Display
4. Passenger Details
5. Exit
Coding
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<process.h>
#include<stdio.h>
#include<fstream.h>
class fc
{
char fn[100];
long fno;
char time[100];
char d[100];
char a[100];
float ep;
float bp;
int es;
int eso;
int bs;
int bso;
public:
fc()
{
strcpy(fn,"");
fno=0;
strcpy(time,"");
strcpy(d,"");
strcpy(a,"");
ep=0.0;
bp=0.0;
es=0;eso=0;bs=0;bso=0;
}
fc(fc &obj)
{
strcpy(fn,obj.fn);
fno=obj.fno;
strcpy(time,obj.time);
strcpy(d,obj.d);
strcpy(a,obj.a);
ep=obj.ep;
bp=obj.bp;
es=obj.es;eso=obj.eso;bs=obj.bs;bso=obj.bso;
}
char* getd(){return d;}
char* geta(){return a;}
char* getfn(){return fn;}
char* gettime(){return time;}
int getes(){return es;}
int getbs(){return bs;}
int geteso(){return eso;}
int getbso(){return bso;}
float getep(){return ep;}
float getbp(){return bp;}
void res(){es--;}
void rbs(){bs--;}
long getfno(){return fno;}
void showfd();
void getfd();
};
void fc :: getfd()
{
cout<<"Enter Name Of The Flight"<<endl;
gets(fn);
cout<<"Enter Flight Number"<<endl;
cin>>fno;
cout<<"Enter Time Of Flight"<<endl;
gets(time);
cout<<"Enter Departure And Arrival
Destination(In Capital): "<<endl;
gets(d);
gets(a);
cout<<"Enter Business Class Seats And Their
Price"<<endl;
cin>>bso>>bp;
cout<<"Enter Economy Class Seats And Their
Price"<<endl;
cin>>eso>>ep;
es=eso;
bs=bso;
}
void fc :: showfd()
{
cout<<"Name Of Flight: ";
puts(fn);cout<<endl;
cout<<"Flight Number; ";
cout<<fno<<endl;
cout<<"Flight Time: ";
puts(time);cout<<endl;
cout<<"Departure And Arrival Destination (In
Capital): ";
cout<<d<<" To "<<a;cout<<endl;
cout<<"Business Class Seat And Their Price: ";
cout<<endl<<bs<<endl<<"Rs. "<<bp<<endl;
cout<<"Economy Class Seat And Their Price: ";
cout<<endl<<es<<endl<<"Rs. "<<ep<<endl;
}
void ff(fc obj)
{
fstream fout;
fout.open("flight.dat",ios::out|ios::binary|ios:
:app);
fout.write((char*)&obj,sizeof(obj));
}
class pc
{
char name[100];
char add[100];
long phone;
long regis;
char fseat;
char sex;
public:
pc()
{strcpy(name,"");strcpy(add,"");phone=0.0;regis=
0.0;fseat=' ';sex=' ';
}
char* getname(){return name;}
char getfseat(){return fseat;}
long getregis(){return regis;}
void getpd();
void showpd();
};
void pc::getpd()
{
cout<<"Enter Name Of The Passenge ";
gets(name);
cout<<"Enter Adress ";
gets(add);
cout<<"Enter Phone Number And Identification
Number ";
cin>>phone>>regis;
cout<<"Enter Gender(M/F) ";
cin>>sex;
cout<<"Choose Economy Or Business Class(E/B): ";
cin>>fseat;
}
void pc::showpd()
{
cout<<"Name Of The Passenge ";
puts(name);
cout<<"Adress ";
puts(add);
cout<<"Phone Number And Identification Number
"<<endl;
cout<<phone<<endl;
cout<<regis<<endl;
cout<<"Gender ";
cout<<sex; cout<<endl;
}
void pf(pc obj)
{
fstream fout;
fout.open("Passenger.dat",ios::out|ios::app|ios:
:binary);
fout.write((char*)&obj,sizeof(obj));
fout.close();
}
void pl(long id)
{
fstream fout; pc obj;
fout.open("Passenger.dat",ios::in|ios::binary);
while(fout.read((char*)&obj,sizeof(obj)))
if(obj.getregis()==id)
obj.showpd();
fout.close();
}
class ticket
{
char name[100];
char fseat;
char fn[100];
long fno;
char time[100];
char d[100];
char a[100];
int seatno;
long regis;

public:
void setticketdata(pc obj1,fc obj2)
{
strcpy(name,obj1.getname());
fseat=obj1.getfseat();
regis=obj1.getregis();
strcpy(fn,obj2.getfn());
fno=obj2.getfno();
strcpy(time,obj2.gettime());
strcpy(d,obj2.getd());
strcpy(a,obj2.geta());
int y;
if(obj1.getfseat()=='E')
y=(obj2.geteso()-obj2.getes());
else
y=(obj2.getbso()-obj2.getbs());
seatno=y;
}
void showdata()
{
cout<<"Flight Name: "<<fn<<endl;
cout<<"Id Number: "<<regis<<endl;
cout<<"Flight Number: "<<fno<<endl;
cout<<"Time :"<<time<<endl;
cout<<"Class: "<<fseat<<endl;
cout<<"Seat Number: "<<seatno<<endl;
cout<<"From "<<d<<" To "<<a<<endl;
}
long getregis(){return regis;}
};
void createticket(pc obj1,fc obj2)
{
ticket obj;
obj.setticketdata(obj1,obj2);
fstream fout;
fout.open("ticket.dat",ios::out|ios::binary|ios:
:app);
fout.write((char*)&obj,sizeof(obj));
}
void showticket(long id)
{
ticket obj;
fstream fin;
fin.open("ticket.dat",ios::in|ios::binary);
while(fin.read((char*)&obj,sizeof(obj)))
if(id==obj.getregis())
obj.showdata();

}
class booking
{
char a[100];
char d[100];
public:
int bookingf();
};
int booking :: bookingf()
{
cout<<"Enter Departure and Arrival Destination
(In Capital); "<<endl;
gets(d);gets(a);
fstream fin;
fin.open("flight.dat",ios::in|ios::binary);
fc obj, obj2[100],objm;int i=0;long fn;int j;int
n;
pc pcobj;float price =0; int p=0 ; int k=0;
while(fin.read((char*)&obj,sizeof(obj)))
if(strcmp(d,obj.getd())==0&&strcmp(a,obj.geta())
==0)
{obj2[i]=obj;
i++;

if(i==0)
{
cout<<"Flight Not Found ";
return 0;
}
else
for(j=0;j<i;j++)
obj2[j].showfd();
cout<<endl<<"Choose Flight(FLight Number) ";
cin>>fn;
for(j=0;j<i;j++)
if(obj2[j].getfno()==fn)
{
obj=obj2[j];
k++;
}
if(k==0)
return 0;
cout<<"Welcome to "<<obj.getfn()<<"
Flight"<<endl;
cout<<"Economy Seats Available
"<<obj.getes()<<endl;
cout<<"Business Seats Available
"<<obj.getbs()<<endl;
cout<<"Enter Number Of Seats ";
cin>>n;
for(j=0;j<n;j++)
{
cout<<"Enter Passenger "<<j+1<<" Details"<<endl;
pcobj.getpd();
pf(pcobj);
if(pcobj.getfseat()=='E')
{
price=price+obj.getep();
obj.res();
}
else
{
price=price+obj.getbp();
obj.rbs();
}
createticket(pcobj,obj);
}

fin.close();
fstream fout;
fout.open("flight.dat",ios::out|ios::in|ios::bin
ary);
while(fout.read((char*)&objm,sizeof(objm)))
{
p=fout.tellg()-sizeof(objm);
if(objm.getfno()==fn)
{
fout.seekp(p);
fout.write((char*)&obj,sizeof(obj));
break;
}
}
fout.close();
cout<<endl<<"Total Bill: Rs. "<<price<<endl;
cout<<"Payment Is Done ";
cout<<"Thank You";
return 1;
}
void main()
{
clrscr();
int ch;
cout<<"1. Flight Database"<<endl;
cout<<"2. Booking"<<endl;
cout<<"3. Ticket Display"<<endl;
cout<<"4. Passenger Details"<<endl;
cout<<"5. Exit"<<endl;
cout<<"Enter Choice"<<endl;
cin>>ch;
fc obj1;char f='y';booking obj2;long id;
switch (ch)
{
case 1:
while(f=='y')
{
obj1.getfd();
ff(obj1);
cout<<"Do You Want To Enter More Flights(y/n)
";cin>>f;
}
break;
case 2:
if(obj2.bookingf()==0)
cout<<"Something Wrong Sorry";
break;
case 3:
cout<<"Enter Identification Number ";
cin>>id;
showticket(id);
break;
case 4:
cout<<"Enter Identification Number ";
cin>>id;
pl(id);
break;
case 5:
exit(0);
default:
cout<<"Something Wrong Sorry";
}
getch();
}
Output Screens
Entering Flight Data

Booking Flight
Displaying Ticket
Displaying Passengers Data
Bibliography

www.google.com

www.wikipedia.com

www.slideshare.com

Computer Science BY Sumita


Arora

S-ar putea să vă placă și