0% found this document useful (0 votes)
56 views

Term Paper: Airline Ticket Reservation System

This document contains the source code for an airline ticket reservation system. The code includes classes for reservations with fields like name, age, gender, flight details. Functions allow inputting a new reservation, cancelling by reservation code, and viewing reservations by flight code and date. The main menu drives the program, allowing the user to make selections to reserve, cancel, view bookings, or exit. The code uses files to store and retrieve reservation records from disk.

Uploaded by

Dawn Cyriac
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Term Paper: Airline Ticket Reservation System

This document contains the source code for an airline ticket reservation system. The code includes classes for reservations with fields like name, age, gender, flight details. Functions allow inputting a new reservation, cancelling by reservation code, and viewing reservations by flight code and date. The main menu drives the program, allowing the user to make selections to reserve, cancel, view bookings, or exit. The code uses files to store and retrieve reservation records from disk.

Uploaded by

Dawn Cyriac
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

TERM PAPER

AIRLINE TICKET RESERVATION


SYSTEM.

Submitted in the partial fulfillment of the Degree


of
B Tech-M Tech(Dual) CSE
In
Computer Science and Engineering

Submitted by:

Submitted To:

Dawn Cyriac

Mr.Raj Karan Singh

11006841

Faculty of CSE 202

RK2002B42

K2002

SOURCE CODE
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<string.h>
#include<fstream.h>
#include<stdlib.h>
const char *AIR= "air.dat";
const char *TMP="tmpry.dat";
int rcod,contr;
char f[6]
[10]={"Delhi\0","Delhi\0","Banglore\0","chennai\0","Hyderbad\0","Lucknow\0"};
char t[6]
[10]={"Mumbai\0","Cochin\0","Delhi\0","Mumbai\0","Delhi\0","Mumbai\0"};
char d[6]
[10]={"Monday\0","Tuesday\0","Wednesday\0","Thursday\0","Friday\0","Saturday\
0"};
char tim[6][10]={"09:30\0","10:30\0","11:30\0","12:30\0","14:30\0","16:30\0"};
int fa[6]={3500,6500,4500,4000,4250,6300};
class reserv
{
public:
char name[31],gend,day[10],from[15],to[15],time[6];

int fcode,mm,dd,yy,age,fare,rcode;
reserv()
{
strcpy(name,"NONAME");
gend='M';
strcpy(day,"DAY");
strcpy(from,"FROM");
strcpy(to,"TO");
strcpy(time,"00:00");
fcode=1;
mm=1;
dd=1;
yy=2011;
age=0;
fare=0;
rcode=1000;
}
void input();
void chart();
};

void reserv::input()
{
rc:
clrscr();
cout<<"\t\t Reservation Chart\n\t\t=================";
cout<<"\nFROM
cout<<"\nDelhi

TO

DAY

CODE

Mumbai Monday

TIME FARE";
09:30 3500";

cout<<"\nDelhi

Cochin Tuesday

10:30 6500";

cout<<"\nBanglore Delhi Wednesday 3

11:30 4500";

cout<<"\nChennai Mumbai Thursday 4

12:30 4000";

cout<<"\nHyderbad Delhi Friday

cout<<"\nLucknow Mumbai Saturday 6


cout<<"\n\n\t\t Enter the flight code:";
cin>>fcode;
if(fcode>6||fcode<1)
{
cout<<"\nNot a valid input";
getch();
goto rc;
}
cout<<"\nEnter your name

:";

gets(name);
cout<<"\nEnter your age

:";

cin>>age;
cout<<"\nEnter your gender(M/F)

:";

cin>>gend;
d:
cout<<"\nEnter the date(dd mm yyyy):";
cin>>dd;
cin>>mm;
cin>>yy;
if(dd>30||mm>12)
{
cout<<"\n\n\tInvalid date";
getch();

14:30 4250";
16:20 6300";

goto d;
}
strcpy(from,f[fcode-1]);
strcpy(to,t[fcode-1]);
strcpy(day,d[fcode-1]);
strcpy(time,tim[fcode-1]);
fare=fa[fcode-1];
rcode=++rcod;
cout<<"\n\n\tYour Reservation is done";
getch();
cout<<"\n\n\t\tYour Ticket\n\t\t===========";
cout<<"\n\tName

:"<<name;

cout<<"\n\tAge

:"<<age;

cout<<"\n\tGender

:"<<gend;

cout<<"\n\tResrvation code:"<<rcode;
cout<<"\n\tFrom
cout<<"\n\tTo

:"<<from;
:"<<to;

cout<<"\n\tFlight Code

:"<<fcode;

cout<<"\n\tDate

:"<<dd<<"/"<<mm<<"/"<<yy;

cout<<"\n\tDay

:"<<day;

cout<<"\n\tTime

:"<<time;

cout<<"\n\tFare

:"<<fare;

getch();
}

void reserv::chart()
{
cout<<name<<"

"<<gend<<"

"<<age<<"\n";

getch();
}
void main()
{
int z;
int menu();
ifstream fpv("cod.txt",ios::in);
fpv>>rcod;
fpv.close();
fstream fp,fp1;
reserv obj;
while(1)
{
m:
z=menu();
switch(z)
{
case 1:
obj.input();
fp.open("air.dat",ios::app|ios::binary);
fp.write((char *)&obj,sizeof(obj));
fp.close();
break;
case 2:
int co;
clrscr();
cout<<"\n\n\tEnter your reservation code:";
cin>>co;

fp.open("air.dat",ios::in|ios::binary);
fp1.open("tmpry.dat",ios::out|ios::binary);
while(fp)
{
fp.read((char *)&obj,sizeof(obj));
if(obj.rcode!=co)
{
fp1.write((char *)&obj,sizeof(obj));
contr++;
}
}
int i=0;
fp.close();
fp1.close();
fp.open("air.dat",ios::out|ios::binary);
fp1.open("temp.dat",ios::in|ios::binary);
while(i<contr)
{
fp1.read((char *)&obj,sizeof(obj));
fp.write((char *)&obj,sizeof(obj));
i++;
}
contr=0;
fp.close();
fp1.close();
cout<<"\n\n\tYour ticket has been removed";
getch();
break;

case 3:
int cod,cd,cm,cy;
clrscr();
cout<<"\n\n\tEnter the flight code :";
cin>>cod;
cout<<"\n\tEnter the date(dd mm yyyy):";
cin>>cd>>cm>>cy;
clrscr();
cout<<"\n\n\t\tFLIGHT CODE:"<<cod<<"\n\t\t=============\n";
cout<<"Name

Sex

Age\n";

fp.open("air.dat",ios::in|ios::binary);
while(fp)
{
fp.read((char *)&obj,sizeof(obj));
if(obj.fcode==cod && obj.mm==cm && obj.dd==cd&& obj.yy==cy)
{
obj.chart();
}
}
break;
case 4:
ofstream fpv1("cod.txt",ios::out);
fpv1<<rcod;
fpv1.close();
exit(0);
}
}
ofstream fpv1("cod.txt",ios::out);

fpv1<<rcod;
fpv1.close();
}
int menu()
{
int a;
clrscr();
cout<<"\n\n\t\tMain Menu\n\t\t=========";
cout<<"\n\t1.Reservation";
cout<<"\n\t2.Cancellation";
cout<<"\n\t3.View Chart";
cout<<"\n\t4.Exit";
cout<<"\n\t";
cin>>a;
return(a);
}

You might also like