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

#include<iostream> #include<iomanip> #include<string> using namespace std; int f

ID: 3628433 • Letter: #

Question

#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int firstclass(char ,int seat[]);
int economy(char ,int seat[]);
int main()
{
const int space=25;
int seats[space]={0};
char choice;
int seat;
int position;
string name;
cout << "|                Airline Reservation System               |"<<endl;
    cout << "|               WELCOME TO OR TAMBO AIRPORT               |"<<endl;
    cout << "|FLIGHT CAPACITY 25 SEATS CONCIST OF FIRST & ECONOMY CLASS|"<<endl;
    for(int i=0;i<space;i++)
{
    cout<<" ";
    cout<<" |CHOOSE THE CLASS YOU WOULD LIKE TO TAKE|"<<endl;
cout<<"|    TYPE 'F'"<<setw(50)<<"TYPE 'E' |"<<endl;
cout<<"|FOR FIRST CLASS"<<setw(50)<<"FOR ECONOMY CLASS|"<<endl;
cout<<"PLEASE BOOK YOUR SEAT:";
cin>>choice;
    if(choice!='F' &&choice!='f'&& choice!='e'&&choice!='E')
{
  cout<<"invalid,re-type :";
  cin>>choice;
}
if(choice=='F'|| choice=='f')
{
  seat=firstclass(choice,seats);
  if(seat>0 && seat<14)
  {
  seats[seat]=seat;
     cout<<"HELLO :"<<name<<" YOUR SEAT NO: IS :"<<seat<<endl<<endl;
  cout<<"...................NEXT CUSTOMER...................."<<endl;
        }
}

if(choice=='E'||choice=='e')
{
  position=economy(choice,seats);
  if(position>13 && position<25)
  {
   seats[position]=position;
   cout<<"HELLO :"<<name<<" YOUR SEAT NO: IS :"<<position++<<endl<<endl;
   cout<<"...................NEXT CUSTOMER...................."<<endl;
        }
   }
}
return 0;
}
int firstclass(char choice,int seat[])
{       
int y=1;
  if(choice=='F'||choice=='f')
{
  for(y=1; y<14; y++)
  {
   if(seat[y]==0)
    return y;
  }
  
}
  return y;
}
int economy(char selection,int position[])
{   
    int s;
  if(selection=='E'||selection=='e')
  {
   for(s=14;s<25;s++)
   {
    if(position[s]==0)
     return s;
   }
  }

return s;
}

Explanation / Answer

please rate - thanks

#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int firstclass(char ,int seat[]);
int economy(char ,int seat[]);
int main()
{
const int space=25;
int seats[space]={0};
char choice;
int seat;
int position;
string name;
cout << "|                Airline Reservation System               |"<<endl;
    cout << "|               WELCOME TO OR TAMBO AIRPORT               |"<<endl;
    cout << "|FLIGHT CAPACITY 25 SEATS CONCIST OF FIRST & ECONOMY CLASS|"<<endl;
    for(int i=0;i<space;i++)
{
    cout<<" ";
    cout<<" |CHOOSE THE CLASS YOU WOULD LIKE TO TAKE|"<<endl;
cout<<"|    TYPE 'F'"<<setw(50)<<"TYPE 'E' |"<<endl;
cout<<"|FOR FIRST CLASS"<<setw(50)<<"FOR ECONOMY CLASS|"<<endl;
cout<<"PLEASE BOOK YOUR SEAT:";
cin>>choice;
    if(choice!='F' &&choice!='f'&& choice!='e'&&choice!='E')
{
cout<<"invalid,re-type :";
cin>>choice;
}
if(choice=='F'|| choice=='f')
{
seat=firstclass(choice,seats);
if(seat>0 && seat<14)
{
seats[seat]=seat;
     cout<<"HELLO :"<<name<<" YOUR SEAT NO: IS :"<<seat<<endl<<endl;
cout<<"...................NEXT CUSTOMER...................."<<endl;
        }
if(seat<0)
    {cout<<"I'm sorry first class is full, is economy class acceptable?";
    cout<<"Y for yes, N for No: ";
    cin>>choice;
    if(choice=='Y'||choice=='y')
         choice='e';
    else
       cout<<"The plane is full!! Next Flight leaves in 5 Hours' Time ";
    }
}

if(choice=='E'||choice=='e')
{
position=economy(choice,seats);
if(position>13 && position<25)
{
   seats[position]=position;
   cout<<"HELLO :"<<name<<" YOUR SEAT NO: IS :"<<position++<<endl<<endl;
   cout<<"...................NEXT CUSTOMER...................."<<endl;
        }
   }
}
return 0;
}
int firstclass(char choice,int seat[])
{      
int y=1;
if(choice=='F'||choice=='f')
{
for(y=1; y<14; y++)
{
   if(seat[y]==0)
    return y;
}

}
return -1;
}
int economy(char selection,int position[])
{  
    int s;
if(selection=='E'||selection=='e')
{
   for(s=14;s<25;s++)
   {
    if(position[s]==0)
     return s;
   }
}

return s;
}