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

can someone help me with this coding this please Write a program to assign passe

ID: 3633563 • Letter: C

Question

can someone help me with this coding this please

Write a program to assign passengers seats in an airplane. Assume a small plane with seat numbering as follows.
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
The program should display the seat pattern, with an X marking the seats already assigned. For example, after seats 1A, 2B, and 4C are taken, the display should look like this:
1 X B C D
2 A X C D
3 A B C D
4 A B X 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
After displaying the seats available, the program prompts for the seat desired, the user types in a seat, and then the display of the available seats is updated. This continues until all seats are filled or until the user signals that the program should end. If the user types in a seat that is already assigned, the program should say that the seat is occupied and ask for another choice.
Your program should read the current seat assignment from a file and when the program ends it should update the file with the new seating assignment.
Your program should have at least three functions: a function to read the seat assignment from a file, a function to assign seats, and the function to write the seating assignment back to the file when the program ends.

Explanation / Answer

please rate - thanks

#include <iostream>
#include <cstring>
using namespace std;
void drawplane(char[][4]);
void chooseseat(int&,int&,char[][4]);
void clearseats(char[][4]);
int main()
{char seats[7][4];
char more;
int row,col;
string temp;
int full=0;
int i,j;
clearseats(seats);   
drawplane(seats);
do
{
   chooseseat(row, col,seats);
   seats[row][col]='X';
   full++;
drawplane(seats);
if(full==28)
    {cout<<"Plane full "<<endl;
     system("pause");
     return 1;
     }
cout<<"more seats to be selected(y/n)";
cin>>more;
more=toupper(more);
}while(more=='Y');

}

void drawplane(char seats[][4])
{
int i,j;
for(i=0;i<7;i++)
{cout<<"Row "<<(i+1)<<" ";
   for(j=0;j<4;j++)
    { cout<<seats[i][j]<<" ";
       if(j==1)
           cout<<" ";
    }
    cout<<endl;
    }
   
                  
return;   
}


void chooseseat(int &row,int &col,char seats[][4])
{
bool goodseat=false;
char seatcol;
do
{
do{
cout<<"Enter Seat row desired 1-7 ";
cin>>row;
if(row<1||row>7)
   cout<<"invalid row ";
}while(row<1||row>7);
row--;
cout<<"Enter Seat desired A-D ";
    cin>>seatcol;
    seatcol=toupper(seatcol);
    if(seats[row][seatcol-'A']!=seatcol)
       {cout<<"improper seat selection - choose again ";
       goodseat=false;
       }
    else
        goodseat=true;
col=seatcol-'A';
if(goodseat)
   {if( seats[row][col]=='X')
        goodseat=false;       
   if(!goodseat)
     cout<<"Seat already chosen-rechoose ";
     }
}while (!goodseat);


return;
}

void clearseats(char seats[][4])
{int i,j;
char val[]={'A','B','C','D'};
for(i=0;i<7;i++)
   for(j=0;j<4;j++)
        seats[i][j]=val[j];
                     
return;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote