0% found this document useful (0 votes)
95 views4 pages

Airline Reservation

Uploaded by

bezi Tigistu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views4 pages

Airline Reservation

Uploaded by

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

#include <iostream>

#include <string>
using namespace std;
const int MAX_SEATS = 20;
int main() {
string seats[MAX_SEATS];
int choice, seatNumber;
string passengerName;

for (int i = 0; i < MAX_SEATS; ++i) {


seats[i] = "Available";
}
do {
cout << "\n WELCOME TO UNITED AIRLINES " << endl;
cout << "\nAirline Reservation System Menu" << endl;
cout << "1. Book a Seat" << endl;
cout << "2. Display Seat Status" << endl;
cout << "3. Cancel Reservation" << endl;
cout << "4. Exit" << endl;

cout << "Enter your choice: ";


cin >> choice;

switch (choice) {
case 1:
cout << "1. Economy Class" << endl;
cout << "2. Business Class" << endl;
int classChoice;
cin >> classChoice;
if (classChoice == 1) {
cout << "Enter seat number to book (0-9): ";

cin >> seatNumber;

if (seatNumber < 0 || seatNumber > 9) {

cout << "Invalid seat number!" << endl;


} else if (seats[seatNumber] == "Available") {
cout << "Enter passenger name: ";
cin.ignore();
getline(cin, passengerName);
seats[seatNumber] = passengerName;
cout << "Seat " << seatNumber << " booked successfully for " << passengerName << "."
<< endl;
} else {
cout << "Seat " << seatNumber << " is already booked." << endl;
}
} else if (classChoice == 2) {

cout << "Enter seat number to book (10-19): ";

cin >> seatNumber;

if (seatNumber < 10 || seatNumber > 19) {

cout << "Invalid seat number!" << endl;


} else if (seats[seatNumber] == "Available") {
cout << "Enter passenger name: ";
cin.ignore();
getline(cin, passengerName);
seats[seatNumber] = passengerName;
cout << "Seat " << seatNumber << " booked successfully for " << passengerName << "."
<< endl;
} else {
cout << "Seat " << seatNumber << " is already booked." << endl;
}
} else {
cout << "Invalid class choice. Please try again." << endl;
}
break;
case 2:
cout << "Seat Status:" << endl;
for (int i = 0; i < MAX_SEATS; ++i) {
cout << "Seat " << i << ": " << seats[i] << endl;
}
break;
case 3:
cout << "Enter seat number to cancel (1-20): ";
cin >> seatNumber;
if (seatNumber < 1 || seatNumber > 20) {
cout << "Invalid seat number!" << endl;
} else {
cout << "Enter passenger name: ";
cin.ignore();
getline(cin, passengerName);
if (seats[seatNumber] == passengerName) {
seats[seatNumber] = "Available";
cout << "Reservation cancelled successfully." << endl;
} else {
cout << "Invalid passenger name or seat number." << endl;
}
}
break;
case 4:
cout << "Exiting the system." << endl;
break;
default:
cout << "Invalid choice. Please try again." << endl;
break;
}
} while (choice != 4);
return 0;
}

You might also like