Programming Language: C++
Develop a seat reservation system for your airline.
Consider the following airline seating pattern:
A 1 2 3 4 5 6 7 8 9 …… 100
B 1 2 3 4 5 6 7 8 9 …… 100
AISLE
C 1 2 3 4 5 6 7 8 9 …… 100
D 1 2 3 4 5 6 7 8 9 …… 100
Either use 2D STL array (array that contains array) or 4 single dimensional STL arrays of size 100. Write a program to display a menu to the user with the options to reserve a seat of choice, reserve a window seat, reserve an aile seat, reserve a seat (any available), withdraw reservation, update reservation (change seat) and display available seats.
Display available seats after each selection. For example if user reserves seat 5 in the row A, it should display:
A 1 2 3 4 X 6 7 8 9 …… 100
B 1 2 3 4 5 6 7 8 9 …… 100
AISLE
C 1 2 3 4 5 6 7 8 9 …… 100
D 1 2 3 4 5 6 7 8 9 …… 100
In case seats are not available, display appropriate messages.
I have provided the screenshots for this program. Also, code is given at the end.
#include <iostream>
#include <stdlib.h>
#include <limits>
#include <vector>
using namespace std;
void displaySeats(vector<vector<int> > seats)
{
for(int i=0; i<seats.size(); i++) {
cout << (char)('A'+i) << " ";
for(int j=0; j<seats[i].size(); j++) {
if(seats[i][j]) {
cout << seats[i][j] << " ";
} else {
cout << "X" << " ";
}
}
if(i==1) {
cout << endl << endl << "\t" <<
"AISLE";
}
cout << endl << endl;
}
}
void displayMenu()
{
cout << "\t Menu \t" << endl;
cout << "1. Reserve a seat of choice." << endl;
cout << "2. Reserve a window seat." << endl;
cout << "3. Reserve an aisle seat." << endl;
cout << "4. Reserve a seat (any available)" <<
endl;
cout << "5. Withdraw reservation" << endl;
cout << "6. Update reservation" << endl;
cout << "7. Display available seats" << endl;
cout << "Enter your choice: ";
}
void reserveSeatOfChoice(vector<vector<int> >
&seats)
{
int col;
char row;
char choice = 'y';
while(choice == 'y') {
cout << "Enter row A/B/C/D (capital)" << endl;
cin >> row;
cin.ignore(numeric_limits<streamsize>::max(),'\n');
cout << "Enter seat number (1-100)" << endl;
cin >> col;
cin.ignore(numeric_limits<streamsize>::max(),'\n');
if(row >= 'A' && row <= 'D' && col >= 1
&& col <= 100) {
if(seats[row-'A'][col-1]) {
seats[row-'A'][col-1] = 0;
cout << "Congratulations, your seat is booked at " <<
(char)row << col << endl << endl;
displaySeats(seats);
return;
}
else {
cout << "Sorry,seat already booked. Try again.(y/n) "
<< endl;
}
}
else {
cout << "Invalid. Try again(y/n)";
}
cin >> choice;
cin.ignore(numeric_limits<streamsize>::max(),'\n');
}
}
void reserveWindowSeat(vector<vector<int> >
&seats)
{
// Check in row A
for(int j=0; j<100; j++) {
if(seats['A'-'A'][j]){
seats['A'-'A'][j]=0;
cout << "Congratulations, your seat is booked at " <<
(char)'A' << j+1 << endl;
displaySeats(seats);
return;
}
}
// Check in row D
for(int j=0; j<100; j++) {
if(seats['D'-'A'][j]){
seats['D'-'A'][j]=0;
cout << "Congratulations, your seat is booked at " <<
(char)'D' << j+1 << endl;
displaySeats(seats);
return;
}
}
cout << "Sorry. All Window seats are booked.";
}
void reserveAisleSeat(vector<vector<int> >
&seats)
{
// Check in row B
for(int j=0; j<100; j++) {
if(seats['B'-'A'][j]){
seats['B'-'A'][j]=0;
cout << "Congratulations, your seat is booked at " <<
(char)'B' << j+1 << endl;
displaySeats(seats);
return;
}
}
// Check in row C
for(int j=0; j<100; j++) {
if(seats['C'-'A'][j]){
seats['C'-'A'][j]=0;
cout << "Congratulations, your seat is booked at " <<
(char)'C' << j+1 << endl;
displaySeats(seats);
return;
}
}
cout << "Sorry. All Aisle seats are already
booked.";
}
void reserveAnySeat(vector<vector<int> >
&seats)
{
for(int i=0; i<4; i++) {
for(int j=0; j<100; j++) {
if(seats[i][j]) {
seats[i][j] = 0;
cout << "Congratulations, your seat is booked at " <<
(char)('A'+i) << j+1 << endl;
displaySeats(seats);
return;
}
}
}
cout << "Sorry. All seats are already booked.";
}
void withdraw(vector<vector<int> > &seats)
{
int col;
char row;
char choice = 'y';
while(choice == 'y') {
cout << "Enter row A/B/C/D (capital)" << endl;
cin >> row;
cin.ignore(numeric_limits<streamsize>::max(),'\n');
cout << "Enter seat number (1-100)" << endl;
cin >> col;
cin.ignore(numeric_limits<streamsize>::max(),'\n');
if(row >= 'A' && row <= 'D' && col >= 1
&& col <= 100) {
if(seats[row-'A'][col-1]==0) {
seats[row-'A'][col-1] = col;
cout << "Seat withdrawn." << endl;
displaySeats(seats);
return;
}
else {
cout << "This seat is not reserved. Try again?(y/n) ";
}
}
else {
cout << "Invalid. Try again(y/n) ";
}
cin >> choice;
cin.ignore(numeric_limits<streamsize>::max(),'\n');
}
}
void update(vector<vector<int> > &seats)
{
cout << "First withdraw the previous reservation. " <<
endl;
withdraw(seats);
cout << "Enter the new Seat of your choice. " <<
endl;
reserveSeatOfChoice(seats);
}
int main() {
vector<vector<int> >
seats(4,vector<int>(100));
for(int i=0; i<4; i++) {
for(int j=0; j<100; j++) {
seats[i][j] = j+1;
}
}
char ch = 'y';
while(ch == 'y') {
int choice;
system("cls");
displayMenu();
cin >> choice;
cin.ignore(numeric_limits<streamsize>::max(),'\n');
switch(choice)
{
case 1:
reserveSeatOfChoice(seats);
break;
case 2:
reserveWindowSeat(seats);
break;
case 3:
reserveAisleSeat(seats);
break;
case 4:
reserveAnySeat(seats);
break;
case 5:
withdraw(seats);
break;
case 6:
update(seats);
break;
case 7:
displaySeats(seats);
break;
default:
cout << "Invalid choice." << endl;
}
cout << "Continue? (y/n) ";
cin >> ch;
cin.ignore(numeric_limits<streamsize>::max(),'\n');
}
cout << "Thank you." << endl;
}
Programming Language: C++ Develop a seat reservation system for your airline. Consider the following airline seating...
Programming language C++. (Airline Reservations System) A small airline has just purchased a computer for its new au- tomated reservations system. You have been asked to develop the new system. You’re to write an app to assign seats on each flight of the airline’s only plane (capacity: 10 seats). Display the following alternatives: Please type 1 for First Class and Please type 2 for Economy. If the user types 1, your app should assign a seat in the first-class section...
For this week's assignment , create and complete a Windows application for the following question. Airline Reservation System: An airline has just bought a computer for its new reservation system. Develop a new system to assign seats on the new airplane( capacity: 10 seats) Display the following alternatives: "Please type 1 for first class, and please type 2 for Economy". If the user enters 1, your application should assign a seat in the first class( seats 1-5). If the user...
Program Description: A bus has 28 seats, arranged in 7 rows and 4 columns: This seating arrangement is mapped, row-wise, to a 1D-array of size 28: 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 0 1 2 3 21 22 23 24 25 Implement a well-structured Java program to enable a user to make and cancel seat reservations for the bus. The program uses Array to store the reservation information: 0...
C++ Help please- kind of long. The aim is to implement a seat reservation system for a passenger airplane. We assume a small airplane with 10 rows and 4 seats per row. We assume that the seat chart is initially stored in a file “chartIn.txt” in the following format: 1 A B C D 2 A B C D 3 A B C D 4 A B C D 5 A B C D 6 A B C D 7 ...
A bus has 28 seats, arranged in 7 rows and 4 columns: This seating arrangement is mapped, row-wise, to a 1D-array of size 28: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 Implement a well-structured C program to enable a user to make and cancel seat reservations for the bus. The program uses a text-file seats.txt to store the reservation...
The Course Project can be started in Week 7 and is due by 11:59 pm CT Saturday of Week 8. It must follow standard code formatting and have a comment block at the top of the code file with a detailed description of what the program does. Functions must have a comment block with a detailed description of what it does. Pseudocode must be provided in the comment block at the top of the file. This program will allow the...
C# WINDOWS FORMS APPLICATION (not CONSOLE APPLICATION ) (Please screenshot window form of this program and write code on computer. Thank you very much !) For this week's assignment , create and complete a Windows application for the following question. Airline Reservation System: An airline has just bought a computer for its new reservation system. Develop a new system to assign seats on the new airplane( capacity: 10 seats) Display the following alternatives: "Please type 1 for first class, and...
P7.5– A theater seating chart is implemented as a two-dimensional array of ticket prices, like this: 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 20 20 30 30...
Hi I need help with a java program that I need to create a Airline Reservation System I already finish it but it doesnt work can someone please help me I would be delighted it doesnt show the available seats when running the program and I need it to run until someone says no for booking a seat and if they want to cancel a seat it should ask the user to cancel a seat or continue booking also it...
(Airline Reservations System) A small airline has just purchased a computer for its new automated reservations system. The president has asked you to program the new system. You'll write a program to assign seats on each flight of the airline's only plane (capacity: 10 scats).Your program should display the following menu of alternatives:Please type 1 for "first class"please type 2 for "economy"If the person types 1 , then your program should assign a seat in the first class section (seats...