This is my code in c++. When the chosen class is full I want the code to automatically assign it to the next available class (Economy). Also when the economy class is full I want the code to automatically assign it to the next available First Class seat.  #include using namespace std;    void ShowInfo(); void printInfo(char input[9][4]); void DesiredRow(int row[2], char seat);   int main () {     int ROW = 9, SEATS = 4;     int row[9];     char airchar[9][4];     char seat;     string answer;     string ticket;     string name;     string newanswer;          for (int i = 0; i < ROW; i++)     {         for (int j = 0; j < SEATS; j++)         {             airchar[i][j] = '*';         }     }          cout << "Please enter your full name: " << endl;     getline(cin, name);          while ("Yes")     {         cout << " Do you wish to book a seat: " << endl;         cout << " Yes or No: " << endl;         cin >> answer;         if (answer == "Yes")     {         ShowInfo();         cin >> ticket;                  printInfo(airchar);         cout << "Desired Row? " << endl;         cin >> row[0];                      cout << "Desired Seat (A, B, C, D) : "<> seat;         DesiredRow(row, seat);          if (ticket == "FS")     {         if (row[0] + 1 || row[0] + 1 == 2)         {             if (airchar[row[0]][row[1]] == '*')             {                 airchar[row[0]][row[1]] = 'X';                 printInfo(airchar);             }         }         else if(airchar[row[0]][row[1]] == 'X')         {             cout<<"Message: Seat "<> newanswer;             if (newanswer == "Yes")             {                              }                                   }         else         {             cout << "Wrong class " << endl;         }              }     else if(ticket == "EC")     {         if(row[0]+1 == 3 || row[0]+1 == 4 || row[0]+1 == 5            || row[0]+1 == 6|| row[0]+1 == 7|| row[0]+1 == 8|| row[0]+1 == 9)     {             if(airchar[row[0]][row[1]] == '*')             {                 airchar[row[0]][row[1]] = 'X';                 printInfo(airchar);             }         else if(airchar[row[0]][row[1]] == 'X')         {             cout<<"Message: Seat "<

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This is my code in c++. When the chosen class is full I want the code to automatically assign it to the next available class (Economy). Also when the economy class is full I want the code to automatically assign it to the next available First Class seat. 

#include <iostream>

using namespace std;

  

void ShowInfo();

void printInfo(char input[9][4]);

void DesiredRow(int row[2], char seat);

 

int main ()

{

    int ROW = 9, SEATS = 4;

    int row[9];

    char airchar[9][4];

    char seat;

    string answer;

    string ticket;

    string name;

    string newanswer;

    

    for (int i = 0; i < ROW; i++)

    {

        for (int j = 0; j < SEATS; j++)

        {

            airchar[i][j] = '*';

        }

    }

    

    cout << "Please enter your full name: " << endl;

    getline(cin, name);

    

    while ("Yes")

    {

        cout << " Do you wish to book a seat: " << endl;

        cout << " Yes or No: " << endl;

        cin >> answer;

        if (answer == "Yes")

    {

        ShowInfo();

        cin >> ticket;

        

        printInfo(airchar);

        cout << "Desired Row? " << endl;

        cin >> row[0];

            

        cout << "Desired Seat (A, B, C, D) : "<<endl;

        cin >> seat;

        DesiredRow(row, seat);

    

    if (ticket == "FS")

    {

        if (row[0] + 1 || row[0] + 1 == 2)

        {

            if (airchar[row[0]][row[1]] == '*')

            {

                airchar[row[0]][row[1]] = 'X';

                printInfo(airchar);

            }

        }

        else if(airchar[row[0]][row[1]] == 'X')

        {

            cout<<"Message: Seat "<<row[0] + 1<<seat<<" is already occupied"<<endl;

            cout <<"Book a different seat? " << endl;

            cout << "Yes or No" << endl;

            cin >> newanswer;

            if (newanswer == "Yes")

            {

                

            }

            

            

        }

        else

        {

            cout << "Wrong class " << endl;

        }

        

    }

    else if(ticket == "EC")

    {

        if(row[0]+1 == 3 || row[0]+1 == 4 || row[0]+1 == 5

           || row[0]+1 == 6|| row[0]+1 == 7|| row[0]+1 == 8|| row[0]+1 == 9)

    {

            if(airchar[row[0]][row[1]] == '*')

            {

                airchar[row[0]][row[1]] = 'X';

                printInfo(airchar);

            }

        else if(airchar[row[0]][row[1]] == 'X')

        {

            cout<<"Message: Seat "<<row[0] + 1<<seat<<" is already occupied"<<endl;

        }

     }

        else

        {

            cout<<"Wrong Class"<<endl;

        }

   }//end of else if loop

        } // end of nst loop

        

       

    else if (answer == "No")

    {

        cout << "Have a good day" << endl;

        cout << name << " your current seating plan is" << endl;

        printInfo(airchar);

        return 0;

    }

  

    

        

    row[0] = 0;

    row[1] = 0;

    }// end of while (yes) loop

}

 

void ShowInfo()

{

    cout<<"Rows 1 and 2 are first class (FC)"<<endl;

    cout<<"Rows 3 through 7 are business class (BC)"<<endl;

    cout<<"Rows 8 through 13 are economy class (EC)"<<endl;

    cout<<endl;

    cout<<"* - Available"<<endl;

    cout<<"X - Occupied"<<endl;

    cout<<endl;

    cout << "Enter desired ticket type " << endl;

    cout << "FS - first class \n EC - economy" << endl;

}

 

void printInfo(char input[9][4])

{

   cout << "\t\t"

        << "A\tB\tC\tD" << endl;

 

   for (int i = 0; i < 9; i++)

   {

      cout << "Row " << i+1 << "\t";

      for (int j = 0; j < 4; j++)

      {

         cout << input[i][j] << "\t";

      }

      cout << endl;

   }

}

 

void DesiredRow(int row[2], char seat)

{

    switch (seat)

    {

        case 'A':

            row[0] = row[0] - 1;

            row[1] = 1;

            row[1] = row[1] - 1;

            break;

        case 'B':

            row[0] = row[0] - 1;

            row[1] = 2;

            row[1] = row[1] - 1;

            break;

        case 'C':

            row[0] = row[0] - 1;

            row[1] = 3;

            row[1] = row[1] - 1;

            break;

        case 'D':

            row[0] = row[0] - 1;

            row[1] = 4;

            row[1] = row[1] - 1;

            break;

    }

    

}

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education