Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Option 1 (Display Seat Chart): The program calls a function that displays the se

ID: 3822902 • Letter: O

Question

Option 1 (Display Seat Chart): The program calls a function that displays the seat chart from the array seatChart using the format: (file named chartIn.txt)

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 B C D

8         A B C D

9         A B C D

10     A B C D

Option 2 (Reserve Seat): The program calls a function that prompts users for the seat desired as a string (e.g., 3A, 7D, etc.) and then determines the row number and column number of the array element that needs to be accessed. If the seat is available, it reserves it by assigning ‘X’ to the seat and displays a message stating that the seat was reserved. Otherwise it displays a message stating that the seat is not available.

Option 3 (Cancel Reservation): The program calls a function that prompts users for the seat to be canceled as a string (e.g., 3A, 7D, etc.) and then determines the row number and column number of the array element that needs to be accessed. If the seat is available, the program displays an error message stating that the seat to be canceled has not been initially reserved. Otherwise it makes the seat available and displays a message stating that the seat reservation has been cancelled.

PLEASE USE C++ LANGUAGE!!!!!!!!!!!!

create each option as a sperate function and call them in a switch statement in int main()

thank you

Explanation / Answer

#include <iostream>
#include <string>

using namespace std;

char seatcht[10][4];
/*char seatcht[10][4]={
{'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'}, };*/use array declaration or read data from .txt file

int i,j,opt;

for(i=0;i<10;i++)
{
for(j=0;j<4;j++)
{

seatcht[10][4]=fgetc("chartln.txt");

}

}

void displaychart()
{
for(i=0;i<10;i++)
{
cout <<i+1<<" ";
for(j=0;j<4;j++)
{
cout<<seatcht[i][j]<<" ";
  
}
cout<<" ";
}
}

void reserveseat(){
char desireseat[2];
int r,c;
cout<<"Enter Desired Seat no to reserve (eg:3A,7D)";
cin>>desireseat;
r=desireseat[0]-'0';
r=r-1;
if (desireseat[1]=='A'||desireseat[1]=='a')
{
c=0;
}
else if (desireseat[1]=='B'||desireseat[1]=='b')
{
c=1;
}
else if (desireseat[1]=='C'||desireseat[1]=='c')
{
c=2;
}
else if (desireseat[1]=='D'||desireseat[1]=='d')
{
c=3;
}
cout<<r<<c;
if(seatcht[r][c]=='X')
{
cout<<"Sorry The seat is already Booked";
displaychart();
}
else
{
seatcht[r][c]='X';
cout<<"Congrats, Your seat is Booked";
displaychart();
  
}

}

void cancelseat()
{
char desireseat[2],n;
int r,c;
cout<<"Enter Desired Seat no to cancel (eg:3A,7D)";
cin>>desireseat;
r=desireseat[0]-'0';
r=r-1;
if (desireseat[1]=='A'||desireseat[1]=='a')
{
c=0;
n='A';
}
else if (desireseat[1]=='B'||desireseat[1]=='b')
{
c=1;
n='B';
}
else if (desireseat[1]=='C'||desireseat[1]=='c')
{
c=2;
n='c';
}
else if (desireseat[1]=='D'||desireseat[1]=='d')
{
c=3;
n='D';
}

if(seatcht[r][c]=='X')
{
seatcht[r][c]==n;
displaychart();
}
else
{
cout<<"Enter correct seat no";
}

}
int main()
{
do
{
cout << endl << "Select one of the following options (1-3)." << endl;

cout << endl << "1. Display Seat Chart";

cout << endl << "2. Reserve a Seat";

cout << endl << "3. Cancel a Seat ";
  
cin>>opt;

switch(opt)
{
case 1:
displaychart();
break;
case 2:
reserveseat();
break;
case 3:
cancelseat();
break;
default:
break;
}

}while(1);

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote