Ticket Management System in c++


 #include<iostream>
#include<fstream>
#include<string>
using namespace std;
struct Data {
	int tickets;
	int id;
	int seats;
	string airline, place;
	string choose;
	string Fname;
	string Lname;
	string passportNo;
	string CNIC;
};
ofstream seat;
ofstream name;
ofstream cancel;
ifstream full;
Data a, b[200];
void data();
void internatinal();
void local();
void getData();
void seatsData();
void ticket();
void aboutUs();
int main()
{
	int x;
	cout << "                  ==============================================" << endl;
	cout << "                      ---------AIRWAYS RESERVATION----------------" << endl;
	cout << "                       ---------- MAIN MENU----------------  " << endl;
	cout << "                      ---------ENTER YOUR CHOICE------------" << endl;
	cout << endl;
	cout << endl;
	cout << endl;
	cout << "                           PRESS 1 FOR LOCAL BOOKING                 " << endl;
	cout << "                       PRESS 2 FOR INTERNATIONAL BOOKING           " << endl;
	cout << "                           Press 3 For About Us                     <<" << endl;
	cout << endl;
	cout << endl;
	cout << "                   ===============================================" << endl;
	cout << endl;
	cout << endl;
	cout << "Enter the choice:";
	cin >> x;
	if (x == 1)
	{
		local();

	}
	if (x == 2)
	{
		internatinal();
	}
	if (x == 3)
	{
		aboutUs();
		system("CLS");
		main();
		return 0;
	}
	data();
	getData();
	seatsData();
	ticket();
}
void data()
{
	system("CLS");
	cout << "*****************ON WHICH TIME YOU WANT TO TRAVEL**************" << endl;
	cout << "\n\n\n\n";
	cout << "____________________1)11 AM_____________________________" << endl;
	cout << "____________________2) 2 PM______________________________" << endl;
	cout << "____________________3) 9 PM______________________________" << endl;
	cout << "\n\n\n\n";
	cout << "Please Enter the timing:";
	cin >> a.choose;
	cout << "\n\n\n\n";
	cout << "_______________________________________________________________" << endl;
	system("CLS");
}
void internatinal()
{
	system("CLS");


	cout << "**************In which AIRLINE company you want to travel***********" << endl << endl;
	cout << "******************************Enter the Name************************" << endl << endl;
	cout << "\n\n\n\n";
	cout << "PIA" << endl;
	cout << "Air-BLUE" << endl;
	cout << "Arab-EMIRATES" << endl;
	cout << "QATAR-AIRWAYS" << endl;
	cout << "enter your choice";
	cin >> a.airline;
	cout << "\n\n\n\n";
	cout << "_________________________________________________________________" << endl;
	system("CLS");
	cout << "****************Flights avaiable*********************" << endl;
	cout << "\n\n\n\n";
	cout << "*************Enter the Name of destination Please*****" << endl;
	cout << "\n\n\n\n";
	cout << "London" << endl << "Manchester" << endl << "Spain" << endl << "Itlay" << endl << "Germany" << endl << "America ";
	cout << "\n\n\n\n\n\n";
	cout << "Enter your Destination:";
	cin >> a.place;
	cout << "\n\n\n\n";
	cout << "__________________________________________________________________" << endl;
	system("CLS");
}
void local()
{
	system("CLS");
	cout << "**************In which AIRLINE company you want to travel**********" << endl << endl;
	cout << "\n\n\n\n";
	cout << "******************************Enter the Name************************" << endl << endl;
	cout << "\n\n\n\n";
	cout << "PIA" << endl;
	cout << "AIR-BLUE" << endl;
	cout << "\n\n\n\n";
	cout << "Enter your Destination:";
	cin >> a.airline;
	cout << "\n\n\n\n";
	cout << "___________________________________________________________" << endl;
	system("CLS");
	cout << "**************Flights avaiable**************" << endl;
	cout << "\n\n\n\n";
	cout << "**********Enter the destination Please****" << endl;
	cout << "\n\n\n\n";
	cout << "Lahore" << endl << "Quetta" << endl << "Sialkot" << endl;
	cout << endl;
	cout << "\n\n\n\n";
	cout << "Enter your destination:";
	cin >> a.place;
	cout << "\n\n\n\n";
	cout << "_________________________________________________________" << endl;
}
void getData()
{
	system("CLS");

	cout << endl;
	cout << "Enter the Tickets:";
	cin >> a.tickets;
	cout << endl;
	name.open("text.txt", ios::out || ios::app);
	if (!name)
	{
		cout << "Error in opening";
	}
	else
	{
		cout << "===============Please Enter information without space in every line============" << endl;
		cout << endl;
		cout << endl;
		for (int i = 0; i < a.tickets; i++)
		{
			cout << "Enter the First Name for Passenger " << 1 + i << ": ";
			cin >> b[i].Fname;
			name << b[i].Fname << endl;
			cout << "Now Please Enter the Last Name of Passanger " << i + 1 << ": ";
			cin >> b[i].Lname;
			name << b[i].Lname << endl;
			cout << "Enter the passport No of passenger " << i + 1 << ": ";
			cin >> b[i].passportNo;
			name << b[i].passportNo << endl;
			cout << "Enter the CNIC: ";
			cin >> b[i].CNIC;
			name << b[i].CNIC << endl;
			cout << endl;
		}
		name.close();
	}
	full.open("text.txt");
	{
		system("CLS");
		if (!full)
		{
			cout << "Error in opening";
		}
		else
		{
			for (int i = 0; i < a.tickets; i++)
			{
				full >> b[i].Fname;
				full >> b[i].Lname;
				full >> b[i].passportNo;
				full >> b[i].CNIC;

			}
			cout << "************************Please Confirm The Detail*************************" << endl;
			cout << endl;
			cout << endl;
			cout << endl;
			for (int i = 0; i < a.tickets; i++)
			{
				cout << "the name of passinger " << i + 1 << " is:" << b[i].Fname << " " << b[i].Lname << endl;
				cout << "the Passport No of pessinger " << 1 + i << " is:" << b[i].passportNo << endl;
				cout << "The CNIC of pessinger " << i + 1 << " is:" << b[i].CNIC << endl;
				cout << endl;
				cout << endl;
				cin.get();
				cin.ignore();
			}
			full.close();
		}
	}
}

void seatsData()
{

	seat.open("text.txt", ios::out | ios::app);
	system("CLS");

	cout << "***************Choose the seat No Now****************" << endl;
	cout << endl;
	cout << endl;
	cout << "1          2           3             4" << endl;
	cout << "5          6           7             8" << endl;
	cout << "9          10          11            12" << endl;
	cout << endl;
	for (int i = 0; i <a.tickets; i++)
	{
		cout << "Enter the seat No for ticket " << i + 1 << ":";
		cin >> b[i].seats;

	}

	for (int i = 0; i <a.tickets; i++)
	{
		if (b[i].seats>12)
		{
			cout << "This seat is not availaible" << endl;
			cout << "Please select the another seat" << endl;
			break;
		}
		else if (b[i].seats == b[i + 1].seats)
		{
			cout << "This seat is already booked" << endl;
			cout << "Please select another seat" << endl;
			cin.get();
			seatsData();
			cin.ignore();
		}

		else
		{
			cout << "OK!     Seat is booked" << endl;
			cout << "your seat No is:" << b[i].seats << endl;
			cin.get();
			seat << b[i].seats << endl;
			cin.ignore();
		}
	}
	seat.close();

}
void ticket()
{
	system("CLS");
	cout << "-----------------------------Your Ticket is-------------------------" << endl;
	cout << endl;
	cout << endl;
	cout << endl;
	cout << "You had booked " << a.tickets << " tickets" << endl;
	cout << endl;
	cout << endl;
	for (int i = 0; i < a.tickets; i++)
	{
		cout << "---------------Ticket No " << i + 1 << endl;
		cout << "***************************************" << endl;
		cout << "Your Name is:" << b[i].Fname << " " << b[i].Lname << endl;
		cout << "Your passport No is " << b[i].passportNo << endl;
		cout << "Your CNIC number is " << b[i].CNIC << endl;
		cout << "Your Airline is:" << a.airline << endl;
		cout << "Your are traveling from Karachi to " << a.place << endl;
		cout << "Your timming is " << a.choose << endl;
		cout << "Your seat number is:" << b[i].seats << endl;
		cout << "***************************************" << endl;
		cin.get();
	}
	int a;
	cout << "If you want to cancel the ticket" << endl << endl << endl;
	cout << "                            Than press 1" << endl;
	cin >> a;
	if (a==1)
	{
		cancel.open("text.txt", ios::out | ios::trunc);
		cout << "===============Your Ticket has been cancelled================" << endl;
		cancel.close();
		exit(EXIT_FAILURE);
	}
	system("CLS");
	cout << "+++++++++++++++Instructions++++++++++++++++" << endl;
	cout << endl;
	cout << endl;
	cout << endl;
	cout << "1)Do not Drink Alcohol" << endl;
	cout << endl;
	cout << "2)Do not smoking" << endl;
	cout << endl;
	cout << "3)Do not take any harmful goods" << endl;
	cout << endl;
	cout << "4)About 65Kg Lugiege is allowed" << endl;
	cout << endl;
	cout << "5)Sit at there own seat" << endl;
	cout << endl;
	cout << endl;
	cout << endl;
	cout << "________________________Good Luck___________________________" << endl;
	cout << endl;
	cout << endl;
	cout << endl;
	cout << "-----------------------------------------Have a Save Journey---" << endl;
	cout << endl;
	cout << endl;
	cout << "BYE BYE********************************************************" << endl;
	cin.get();
}
void aboutUs()
{
	cout << "Made by:" << endl;
	cout << "        Bilal Zahid           BS(CS)1A       03-1341922-001" << endl << endl << endl;
	cout << "        Faisal Abdul Ghani    BS(CS)1A       03-134192-012" << endl << endl << endl;
	cout << "        Abdul Wahab Raza      BS(CS)1A       03-134192-005" << endl << endl << endl;
	cin.get();
	cin.ignore();
}      

          

       
 

Comments

Popular posts from this blog

Multiple inheritance,friend function and multiple file in oop(object oriented programming)

Concepts of OOP (object oriented programming)

Concepts in c++........