0% found this document useful (3 votes)
2K views

Flight Reservation System C++ Program

This document contains the code for a C++ airline reservation system. It defines functions for a main menu, reserving seats, viewing flight schedules, and adding new flight and reservation records to text files. The main() function calls the main_menu() function, which displays a menu and calls different functions based on the user's input choice, such as displaying existing reservations, schedules, or allowing new reservations or flights to be added.

Uploaded by

khawaja007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (3 votes)
2K views

Flight Reservation System C++ Program

This document contains the code for a C++ airline reservation system. It defines functions for a main menu, reserving seats, viewing flight schedules, and adding new flight and reservation records to text files. The main() function calls the main_menu() function, which displays a menu and calls different functions based on the user's input choice, such as displaying existing reservations, schedules, or allowing new reservations or flights to be added.

Uploaded by

khawaja007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include <iostream.

h>
#include <conio.h>
#include <fstream.h>
#include <iomanip.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <constream.h>
void reserve_seat();
void seat_reserve();
void flight_schedule();
void main_menu();
void add_res();
void add_f();
struct custom
{
char
fname[5000],nic[5000],clas[5000],origin[5000],destination[5000],f_name[5000],fl_n[5
000],org[5000],dest[5000];
void add_f()
{
ifstream read("f_s.txt",ios::app);
ofstream write("f_s.txt",ios::app);
cout<<endl;
cout<<"What is the no of the flight(in small letters): ";
gets(fl_n);
customer.fl_n[5000]=tolower(customer.fl_n[5000]);
cout<<endl;
cout<<"What is the flight's City of Origin: ";
gets(org);
cout<<endl;
cout<<"What is the flight's City of Destination: ";
gets(dest);
cout<<endl;
cout<<endl<<endl;
while(!read.eof())
{
cout<<endl;
write<<"Flight no: "<<customer.fl_n<<endl;
write<<"City Of Origin: "<<customer.org<<endl;
write<<"City Of Destination: "<<customer.dest<<endl<<endl;
break;
}
read.close();
write.close();
cout<<endl;
cout<<"Flight Schedule Successfully updated !"<<endl;
getch();
main_menu();
}
void add_res()
{
ifstream read("s_r.txt",ios::app);
ofstream write("s_r.txt",ios::app);
cout<<"What is the customer's full name: ";
gets(fname);
cout<<endl<<endl;
cout<<"What is the customer's N.I.C(National Identification Card
Number): ";
gets(nic);
cout<<endl;
cout<<"What is the customer's Chosen Class(First Class or Economy
Class): ";
gets(clas);
cout<<endl;
cout<<"What is the customer's Flight No(in small letters): ";
gets(f_name);
customer.f_name[5000]=tolower(customer.f_name[5000]);
cout<<endl;
cout<<"What is the customer's City of Origin: ";
gets(origin);
cout<<endl;
cout<<"What is the customer's City of Destination: ";
gets(destination);
cout<<endl;
cout<<endl<<endl;
while(!read.eof())
{
cout<<endl;
write<<"Customer's Name: "<<customer.fname<<endl;
write<<"N.I.C(National Identification Card No):
"<<customer.nic<<endl;
write<<"Flight No/Class:
"<<customer.f_name<<"/"<<customer.clas<<endl;
write<<"City Of Origin: "<<customer.origin<<endl;
write<<"City Of Destination: "<<customer.destination<<endl<<endl;
break;
}
read.close();
write.close();
cout<<endl;
cout<<"Seat Successfully reserved !"<<endl;
getch();
main_menu();
}

};
custom customer;
void main()
{
clrscr();
main_menu();
getch();
}
void main_menu()
{
clrscr();
int code;
cout<<" Welcome To My Project !"<<endl;
cout<<endl;
cout<<" Zain's Flight Reservation System"<<endl;
cout<<endl;
cout<<" Main Menu :"<<endl;
cout<<endl;
cout<<" Code: Option:"<<endl;
cout<<endl;
cout<<" 1 Seat Reservations."<<endl;
cout<<endl;
cout<<" 2 Flight Schedule. "<<endl;
cout<<endl;
cout<<" 3 Add a Reservation."<<endl;
cout<<endl;
cout<<" 4 Add a Flight."<<endl;
cout<<endl;
cout<<" 5 Exit"<<endl;
cout<<endl;
cout<<"Please, enter any of those codes to select that specific option: ";
cin>>code;
if (code==1)
{
cout<<endl;
seat_reserve();
getch();
}
if (code==2)
{
cout<<endl;
flight_schedule();
}
if (code==3)
{
cout<<endl;
reserve_seat();
}
if (code==4)
{
cout<<endl;
customer.add_f();
}
if (code==5)
{
exit(1);
}
else if (code!=1 || code!=2 || code!=3 || code!=4 || code!=5)
{
cout<<endl;
cout<<"Code Error !, Please enter from any of the above given Option
codes"<<endl;
getch();
main_menu();
}
}
void seat_reserve()
{
clrscr();
char ch[100];
ifstream read("s_r.txt");
cout<<" Seat Reservations:"<<endl;
cout<<endl;
while(!read.eof())
{
read.getline(ch,100);
cout<<ch;
cout<<endl;
}
read.close();
cout<<endl<<endl;
cout<<"Press any key to go back to the Main Menu !"<<endl;
getch();
main_menu();
}
void flight_schedule()
{
clrscr();
char ch[100];
ifstream read("f_s.txt");
cout<<" Flight Schedule:"<<endl;
cout<<endl;
while(!read.eof())
{
read.getline(ch,100);
cout<<ch;
cout<<endl;
}
read.close();
cout<<endl<<endl;
cout<<"Press any key to go back to the Main Menu !"<<endl;
getch();
main_menu();
}
void reserve_seat()
{
clrscr();
char ch,choice;
cout<<" Seat Reservations:"<<endl;
cout<<endl;
cout<<endl<<endl;
cout<<endl;
customer.add_res();
main_menu();

You might also like