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

What is wrong with my code? This is in C++.. - It says that fly (\"Alfa\",Lsize1

ID: 3832361 • Letter: W

Question

What is wrong with my code? This is in C++.. - It says that fly ("Alfa",Lsize1Left,Lsize1,PassengerList1); is a use of undeclared identifier 'Lsize1Left' Here is the program:

Your employer has determined a market for a simple airline ticketing system for a very simple airline (Tree Top Airways - TTA). The airline only has two aircraft, named ALFA and BRAVO. Initially, the ticket system will determine the number of seats on each plane and in the lounge. The ticketing system is to be installed at the airport ticket booth for the airline and will operate under the following rules:

1) If a party arrives and there is enough room on the plane requested, they are allowed to board and a message to that effect is printed.

2) If a party arrives and there is not enough room on the plane requested due to people already being on the plane, the party is directed to wait in the lounge and a message to that effect is printed.

3) If a party arrives and there is not enough room on the plane requested because the plane is just too small, the party is turned away and a message to that effect is printed.

4) If a party is directed to the lounge and there is not enough room in the lounge, the party is turned away.

5) Parties are never split.

6) A plane will fly whenever it becomes full and a list of all parties on board will be printed.

7)A plane may fly upon a command from the ticket clerk.Again a list of all parties on board will be printed.

8) The ticket clerk will enter when a plane flys and upon the return of the plane the system will move people from the lounge to the plane in the order in which the parties arrived, but will skip parties that cannot fit and search for those which can fit. A list of those parties boarding the plane will be printed.

9) When the airline shuts down for the night, the airplanes will continue to fly and return (without the ticket clerk performing any action) until all parties in the lounge have flown with appropriate messages being printed.

10) Party names do not have a maximum size so they must be handled as C-type strings and dynamically allocated. The commands the system will accept are the following: ALFA BRAVO LOUNGE FLY ARRIVE SHUTDOWN where: is either ALFA or BRAVO. is a name of unlimited length. is an integer number Fields in the input will be separated by some amount of whitespace. The ticket clerk is a terrible typist.

Code is below (Please help me)

#include<iostream>

#include<string>

#include<time.h>

#include <stdlib.h>

using namespace std;

void flightA(int,string[],int,int,int);

void flightB(int, string[],int,int,int);

void fly(string,int,int,string[]);

void flightReturn(string,int,int,string[]);

int main ()

{

  

  

  

string flightChoice;

  

  

  

char ch;

  

  

  

long int loungeA,loungeB;

  

  

  

long int Lsize1,Lsize1Left,Lsize2,Lsize2Left;

  

  

  

string passengerList1[100],passengerList2[100];

  

  

  

int i=0,j=0;

  

  

  

long int passengerList;

string PassengerList1[100];

string PassengerList2[100];

  

  

  

  

  

  

long int partySize;

  

  

  

bool flightAlfa=true;

  

  

  

bool flightAReturn=false,flightBReturn=false;

  

  

  

cout <<"Welcome to Tree Top Airways - TTA"<

  

  

  

cout << "======================================="<

  

  

  

cout<<"Alfa";

  

  

  

cin >> Lsize1;

  

  

  

Lsize1Left=Lsize1;

  

  

  

cout <

  

  

  

cout <<"BRAVO";

  

  

  

cin >> Lsize2;

  

  

  

Lsize2Left=Lsize2;

  

  

  

cout <

  

  

  

cout << "LougeA";

  

  

  

cin >> loungeA;

  

  

  

cout<<"LoungeB";

  

  

  

cout<

  

  

  

do

  

  

  

{

  

  

  

cout<<"FLY";

  

  

  

cin>>flightChoice;

  

  

  

if(flightChoice=="Alfa")

  

  

  

{

  

  

  

flightA(Lsize1,passengerList1,i,Lsize1Left,loungeA);

  

  

  

  

  

  

  

}

  

  

  

else if(flightChoice=="Bravo")

  

  

  

{

  

  

  

cout <<"incorrect flight choice";

  

  

  

exit(0);

  

  

  

}

  

  

  

  

  

  

  

}

  

  

  

while(flightChoice!="N");

  

  

  

cout<

  

  

  

cout<<"Want to fly without filling (Y/N):";

  

  

  

cin>>ch;

  

  

  

if(ch=='y')

  

  

  

fly(flightChoice,0,0,0);

  

  

  

system("pause");

  

  

  

return 0;

  

  

  

}

void flightA(int Lsize1,string passengerList[],int i,int Lsize1Left, int loungeA)

{

  

  

  

int partySize=0;

  

  

  

cout<<"Enter party name: ";

  

  

  

cin>>passengerList[i];

  

  

  

i++;

  

  

  

cout<<"Enter passenger size";

  

  

  

cin>>partySize;

  

  

  

if(partySize>Lsize1Left)

  

  

  

{

  

  

  

if(partySize

  

  

  

{

  

  

  

cout <<"Please wait in the lounge";

  

  

  

loungeA-=partySize;

  

  

  

}

  

  

  

else

  

  

  

cout<< "You are requested to plan your trip later as there is not enough space in the Flight and Lounge. Have a good day!";

  

  

  

  

  

  

  

}

  

  

  

else

  

  

  

cout<<"Your booking is confirmed! Have a safe Flight!";

  

  

  

Lsize1Left-=partySize;

  

  

  

}

fly ("Alfa",Lsize1Left,Lsize1,PassengerList1);

void flightB(int Lsize2,string PassengerList2[],int j,int Lsize2Left, int loungeB)

{

  

  

  

  

  

  

  

{

  

  

  

  

  

  

  

  

  

  

  

int partySize;

  

  

  

cout <<"Enter party name:";

  

  

  

cin >>PassengerList2[j];

  

  

  

j++;

  

  

  

cout <<"Enter passenger size";

  

  

  

cin>>partySize;

  

  

  

if (partySize>Lsize2Left) {

  

  

  

if(partySize

  

  

  

cout<<"Please wait in the lounge";

  

  

  

loungeB-=partySize;

  

  

  

}

  

  

  

else

  

  

  

cout<<"You are requested to plan your trip later as ther is not enough space in the Flight and Lounge. Have a good day!";

  

  

  

}

  

  

  

else

  

  

  

cout <<"Your booking is confirmed! Have a safe flight!";

  

  

  

Lsize2Left-=partySize;

  

  

  

}

  

  

  

fly ("Alpha", Lsize2Left, Lsize2, PassengerList2);

  

  

  

}

void fly(string flightChoice,int LsizeLeft,int Lsize, string PassengerList[])

{

  

  

  

if(LsizeLeft==0 && Lsize!=0)

  

  

  

{

  

  

  

if(flightChoice=="Alfa")

  

  

  

cout <<"Bravo Flight ready to fly";

  

  

  

cout<<"Passenger List";

  

  

  

for (int i=0;i

  

  

  

{

  

  

  

cout<

  

  

  

}

  

  

  

}

  

  

  

else

  

  

  

cout<<"Flying as per clerk entery";

  

  

  

}

void flightReturn(int lounge,string flightChoice, int LsizeLeft,int Lsize, string passengerList[])

{

  

  

  

if(lounge>0)

  

  

  

if(lounge

  

  

  

{

  

  

  

LsizeLeft=Lsize-lounge;

  

  

  

lounge=0;

  

  

  

}

  

  

  

else if(lounge>Lsize ||lounge==Lsize)

  

  

  

{

  

  

  

lounge-=Lsize;

  

  

  

LsizeLeft=0;

  

  

  

fly(flightChoice,LsizeLeft,Lsize,passengerList);

  

  

  

}

  

  

  

  

  

  

  

else

  

  

  

  

  

  

  

cout <<"Flight available";

  

  

  

}

  

  

  

Explanation / Answer

Hi There,

I think I have found out why the code is causing the problem. You are trying to call this function fly("Alfa",Lsize1Left,Lsize1,PassengerList1); from outside any given function. This statement is just above void flightB() function.

fly ("Alfa",Lsize1Left,Lsize1,PassengerList1); <- remove this or put it in appropriate place
void flightB(int Lsize2,string PassengerList2[],int j,int Lsize2Left, int loungeB)
{

This is not a valid declaration. Please remove it, as you are calling the fly() function, not declaring it.

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