of 7

Airlines

Published on January 2017 | Categories: Documents | Downloads: 6 | Comments: 0
113 views

Comments

Content

#include<fstream.h>
#include<process.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<dos.h>
#include<iostream.h>
void res_menu();
void help();
class address
{
protected :
char city[30],post[30],colony[30];
int hno[10], pin[10];
public :
void address_inp()
{
cout<<"\n\n\t\t\t\tENTER YOUR ADDRESS : ";
cout<<"\n\t\tHOUSE NO. : ";
cin>>hno[10];
cout<<"\n\t\tCOLONY : ";
gets(colony);
hh:
if (!isalpha(colony))
{
cout<<"INVALID FORMAT. ENTER IN ALPHABET.";
goto hh;
cout<<"\n\t\tPOST OFFICE : ";
gets(post);
cout<<"\n\t\tCITY : ";
gets(city);
cout<<"\n\t\tPIN CODE NO. : ";
cin>>pin[10];
}
void address_out()
{
cout<<"\n\n\t\t\tENTERED ADDRES IS : "<<hno<<" , "<<colo
ny<<" , "<<post<<" ,"<<city<<" - "<<pin;
}
};
class p_det
{
protected :
address add;
int age;
char name[40];
char sex;
public:
void p_det_inp()
{
cout<<"\n\n\t\t\tENTER YOUR PERSONAL DETAILS : ";
cout<<"\n\n\t\tNAME : ";
gets(name);
cout<<"\n\t\tADDRESS : ";
add.address_inp();
cout<<"\n\t\tAGE : ";
cin>>age;
cout<<"\n\t\tSEX (M/f) : ";
cin>>sex;
}
void p_det_out()

{
cout<<"\n\n\t\t\tENTERED PERSONAL DATA IS : ";
cout<<"\n\n\t\tNAME : ";
puts(name);
cout<<"\n\t\tADDRESS : ";
add.address_out();
cout<<"\n\t\tAGE : ";
cout<<age;
cout<<"\n\t\tSEX (M/F) : ";
cout<<sex;
delay(500);
}
void assign_name(p_det p,char str[]);
};
void p_det :: assign_name(p_det p,char str[])
{
strcpy(str,p.name);
}
class dat
{
int dd,mm,yy;
public :
void dat_inp()
{
h:
cout<<"JOURNEY DETAILS : ";
cout<<"DATE (dd) : ";
cin>>dd;
cout<<"MONTH (mm) : ";
cin>>mm;
if((dd>31) || (mm>12))
{
cout<<"ENTERED DATE IS INVALID !! PLEASE
WRITE IN CORRECT FORMAT.... ";
goto h;
}
cout<<"YEAR (yyyy) : ";
cin>>yy;
}
void dat_out()
{
if( (dd>0 && dd<31) && (mm>0 && mm <13) )
{
cout<<"DATE DETAIS ENTERED BY YOU : "<<dd<<"/"<<
mm<<"/"<<yy;
delay(500);
}
}
};
class res :public dat
{
char fcode[5];char to[15],from[15],via[15];
float fare;
public :
p_det p;
void dest_out()
{
cout<<"FROM : ";
puts(from);
cout<<"VIA : ";

puts(via);
cout<<"TO : ";
puts(to);
}
void res_inp()
{
clrscr();
res_menu();
cout<<"\n\n\t\t\tRESERVATION FORM";
cout<<"\n\n\tEnter flight code : ";
gets(fcode);
if( strcmp(fcode,"0871")==0 )
{
strcpy(from,"LUCKNOW");
strcpy(to,"DELHI");
strcpy(via," ÄÄ ");
fare=100;
}
else if(strcmp(fcode,"0037")==0)
{
strcpy(from,"LUCKNOW");
strcpy(to,"CHENNAI");
strcpy(via,"DELHI");
fare=700;
}
else if(strcmp(fcode,"1070")==0)
{
strcpy(from,"DELHI");
strcpy(to,"COCHIN");
strcpy(via," ÄÄ ");
fare=730;
}
else if(strcmp(fcode,"1007")==0)
{
strcpy(from,"DELHI");
strcpy(to,"BANGALORE");
strcpy(via," ÄÄ ");
fare=800;
}
else if(strcmp(fcode,"1017")==0)
{
strcpy(from,"LUCKNOW");
strcpy(to,"BANGALORE");
strcpy(via,"DELHI");
fare=850;
}
else if(strcmp(fcode,"7001")==0 )
{
strcpy(from,"ALLAHBAD");
strcpy(to,"DELHI");
strcpy(via," ÄÄ ");
fare=80;
}
else
{
clrscr();
cout<<"ERROR";
delay(1000);
strcpy(from,"ERROR");
strcpy(to,"ERROR");

strcpy(via,"ERROR");
exit(0);
}
p.p_det_inp();
dat_inp();
getch();
clrscr();
}
void res_out()
{
cout<<"\n\n\t\t\tRESERVATION ENTRIES";
cout<<"\n\n\tFlight Code : ";
puts(fcode);
p.p_det_out();
dest_out();
dat_out();
}
friend void assign_code(res p,char str[]);
};
void assign_code(res p,char str[])
{
strcpy(str,p.fcode);
}
void menu()
{
clrscr();
cout<<"\n\t\t\t\tMENU";
cout<<"\n\n\t\t1.Reservation";
cout<<"\n\t\t2.Querries";
cout<<"\n\t\t3.Cancellation";
cout<<"\n\t\t4.Help";
cout<<"\n\t\t5.Exit";
getch();
}
void res_menu()
{
cout<<"";
cout<<"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»\n";
cout<<" SAHARA AIRLINES
³\n";
cout<<" ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ1/4\n";
cout<<"RESERVATION / ROUTE / FARE MENU\n";
cout<<" ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\n";
cout<<"ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ\n ";
cout<<" ³SN³FROM
³ TO
³ VIA ³CODE³ TIMING ³DAY ³FARE³\n ";
cout<<" ³ ³
³
³
³
³ARR ³DEP ³
³($) ³\n ";
cout<<" ³1 ³LUCKNOW ³DELHI
³ßßßßß³0871³ 530³1615³MON ³100 ³\n ";
cout<<" ³2 ³LUCKNOW ³CHENNAI ³DELHI³0037³1200³1230³THUR³700 ³\n ";
cout<<" ³3 ³DELHI ³COCHIN ³ßßßßß³1070³1740³1830³FRI ³730 ³\n ";
cout<<" ³4 ³DELHI ³BANGALORE³ßßßßß³1007³2040³2100³SUN ³800 ³\n ";
cout<<" ³5 ³LUCKNOW ³BANGALORE³DELHI³1017³1615³1700³MON ³850 ³\n ";
cout<<" ³6 ³ALLAHBAD³ DELHI ³ÄÄÄÄij7001³0845³0910³SUN ³ 80 ³\n";
cout<<"ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ\n ";
delay(100);
getch();
}
void main()
{
int mch;
res r;
int flag=0,rec=0;

char ch;
do
{
clrscr();
char name[36],code[5],name1[36],code1[5];
char name2[36],code2[5];
int flag=0;
menu();
gotoxy(4,30);
puts("\n\n\n\t\t\tEnter your choice : ");
gotoxy(30,30);
cin>>mch;
switch(mch)
{
/* CASE 1 : WRITES THE INFORMATION */
case 1:
r.res_inp();
fin.open("oldmas.dat",ios::binary |ios::app);
fin.write( (char*)&r,sizeof(r));
fin.close();
fin.open("oldmas.dat",ios::binary |ios::in);
fin1.open("newmas.dat",ios::binary |ios::out);
fin.read( (char*)&r,sizeof(res) );
while(!fin.eof() )
{
fin1.write( (char*)&r,sizeof(res) );
fin.read( (char*)&r,sizeof(res) );
}
fin.close();
fin1.close();
break;
/* CASE 2 : SEARCHING THE INFORMATION */
case 2:
fin.open("newmas.dat",ios::in|ios::binary);
clrscr();
cout<<"\n\n\t\t\tENTER THE NAME : ";
gets(name);
cout<<"\n\t\t\tENTER THE FLIGHT CODE : ";
gets(code);
while( !fin.eof() )
{
assign_code(r,code1);
r.p.assign_name(r.p,name1);
if(strcmpi(name1,name)==0 && strcmp(code1,code
)==0)
{
clrscr();
cout<<"WELCOME TO SAHARA QUERIES";
r.res_out();
rec=1;
cout<<"Press any key to continue....
. ";
getch();
}
fin.read((char *)&r , sizeof(res));
}
fin.close();
clrscr();
if(rec==0)
{

clrscr();
cout<<"RECORD NOT FOUND IN RESERVATION TABLE";
getch();
}
break;
/* CASE 3 : CANCELLATION OF TICKET */
case 3:
cout<<"ENTER THE NAME : ";
gets(name);
cout<<"ENTER THE CODE : ";
gets(code);
cout<<"Checking for record..... ";
fin.open("oldmas.dat",ios::binary | ios::in);
fin1.open("newmas.dat",ios::binary | ios::out);
if(fin==NULL && fin1==NULL)
{
cout<<"NO RECORD FOUND IN RESERVATION TABLE !!!
";
getch();
goto label;
}
else
{
fin.read( (char*)&r,sizeof(res) );
while(!fin.eof() )
{
assign_code(r,code1);
r.p.assign_name(r.p,name1);
cout<<"NAME - 1 AND CODE - 1 : ";
puts(name1);
puts(code1);
getch();
if(strcmpi(name1,name)==0 && strcmp(co
de1,code)==0)
{
cout<<"RECORD FOUND ... ";
cout<<"DELETING, PLEASE WAIT !!
";
}
else
{
fin1.write( (char*)&r ,sizeof(re
s));
}
fin.read( (char*)&r,sizeof(res) );
}
}
fin.close();fin1.close();
cout<<"RECORD MARKED FOR DELETION .... ";
getch();
unlink("oldmas.dat");
fin.open("oldmas.dat",ios::app|ios::binary );
fin1.open("newmas.dat",ios::binary |ios::in);
if(fin1==NULL)exit(0);
else
{
fin1.read( (char*)&r,sizeof(res) );
while(!fin1.eof() )
{
fin.write( (char*)&r,sizeof(res) );

fin1.read( (char*)&r,sizeof(res) );
}
}
fin.close();
fin1.close();
label :
break;
/* CASE 4 : TO PROVIDE HELP */
case 4:
help();
break;
/* CASE 5 : FOR EXIT */
case 5:
puts("EXITING, PLEASE WAIT .... ");
for(int a=1;a<5;a++)
{
puts(" ........... ");
delay(1000);
}
exit(1);
break;
default :
cout<<"\n Out of choice !!! Wanted To Try Again (Y/N) :
";
cin>>ch; break;
}
}
while( (mch>0 && mch<6) || (ch=='y' || ch=='Y') );
delay(2000);
}
void help()
{
clrscr();
cout<<"WELCOME TO HELP";
delay(700);
cout<<"You are provided with airlines's 'MENU'. According to your need,
you may choose any valid option : ";
delay(2000);
cout<<"FOR EXAMPLE : ";
delay(700);
clrscr();
delay(1500);
delay(2000);
menu();
cout<<"IF YOUR CHOICE IS RESERVATION, NUMBER TO BE ENTERED IS 1.";
cout<<"Press Any Key To Continue ... ";
getch();
}

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close