Airplane Board Pass Code (In C ++)
Airplane Board Pass Code (In C ++)
: FA23-BEE-032
Create a function named ReservedSeat to reserve a seat and return true if successful.
Declare a seating plan array and variables for the reserved seat's row and column.
Call ReservedSeat to reserve a seat. If successful:
Create a PassInfo structure for the passenger.
Adjust the seat number based on the row and column.
Call PassengerInfo to input passenger details.
Call OutputSeatingPlan to display the updated plan.
Call BoardingPass to print the boarding pass information.
End.
Code:
#include <iostream>
#include <iomanip>
#include <string>
struct PassInfo
string name;
char gender;
int age;
string seatClass;
int seatNo;
string baggage;
string meal;
};
{
cout << setw(5) << SeatingPlan[i][j] << setw (5) << endl;
if ( row < 0 || row > rows || col < 0 || col >= colm)
return false;
if (SeatingPlan[row-1][col]== 'X')
return false;
cin.ignore();
getline(cin, passenger.name);
}
void BoardingPass(const PassInfo& passenger)
cout << "Name: " << setw(3) << passenger.name << endl;
cout << "Gender : " << setw(3) << passenger.gender << endl;
cout << "Age: " << setw(3) << passenger.age << endl;
cout << "Seat Class: " << setw(3) << passenger.seatClass << endl;
cout << "Seat Number: " << setw(3) << passenger.seatNo << endl;
cout << "Baggage: " << setw(3) << passenger.baggage << endl;
cout << "Meal: " << setw(3) << passenger.meal << endl;
int main()
PassInfo passenger;
PassengerInfo(passenger);
OutputSeatingPlan(SeatingPlan);
BoardingPass(passenger);
return 0;
}
Explanation:
Data Structure:
The program defines a structure called PassInfo to store information about passengers. It includes
fields such as name, gender, age, seat class, seat number, baggage information, and meal
preferences.
Constants:
Constants are set for the number of rows (13) and columns (6) in the airplane seating plan.
Functions:
a. OutputSeatingPlan:
This function displays the current seating plan of the airplane. The seating plan is represented by
a 2D array of characters ('X' indicates reserved seats).
b. ReservedSeat:
Allows a user to reserve a seat by entering the row and column numbers. It checks for seat
availability, validates input, and marks the seat as reserved.
c. PassengerInfo:
Gathers input from the user for passenger details, such as name, gender, age, seat class, seat
number, baggage information, and meal preferences.
d. BoardingPass:
Generates and displays a boarding pass with the passenger's information, including name, gender,
age, seat class, seat number, baggage information, and meal preferences.
Main Function:
The seat number is calculated as row * 10 + col and is assigned to the passenger's seatNo field.
User Interaction:
The program interacts with the user by requesting input for seat reservation and passenger
information.
Output Formatting:
The output is formatted using setw to align and space out the displayed information.
Array Initialization:
The seating plan array is initialized as an empty array, and 'X' is used to represent reserved seats.