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? In C++ Your employer has determined a market for a s

ID: 3826425 • Letter: W

Question

What is wrong with my code? In C++

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) Aplanemayflyuponacommandfromtheticketclerk.Againalistofallpartieson 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 <size>
BRAVO <size>
LOUNGE <size>
FLY <airplane>
ARRIVE <airplane><party><size> SHUTDOWN

where: <airplane> is either ALFA or BRAVO. <party> is a name of unlimited length. <size> is an integer number

Fields in the input will be separated by some amount of whitespace. The ticket clerk is a terrible typist.

Code)

#include <iostream>

using namespace std;

int main ();

{

struct arrive

{

string airplane;

string party;

int size;

};

void fly_plane(string s, vector<arrive> plane)

{

for(auto itr=plane.begin(); itr!=plane.end(); itr++) //printing the party boarding the plane

cout<<itr->party;

if(s=="Alpha")

Alpha=Alpha_original;

else if(s="Bravo")

Bravo=Bravo_original;

for auto itr=plane.end()-1; itr!=plane.begin()-1; itr--) //reset the plane list

plane.popback(itr);

}

int main()

{

int Alpha, Bravo, lounge_size, Alpha_original, Bravo_original;

vector<arrive> lounge;

vactor<arrive> plane;

string party;

string fly;

string v= "Shutdown";

while(1) //keep operating till we get the commands

{

Alpha=Alpha_original;

Bravo=Bravo_original;

int temp=0;

cout<<"Enter 1 for fly, 2 for arrive and 3 for shutdown";

cin>>temp;

if(temp==1)

{

fly_plane(s, plane); //command to fly the plane

}

if(temp==2)

{

arrive n = new arrive();

cin>>n->airplane;

cin>>n->party;

cin>>n->size;

if(n->airplane=="Alpha")

{

if(Alpha_original<size) //plane too small for party

{

cout<<"party returned back";

continue;

}

else if(Alpha<size)

{

if(lounge_size>size) //if lounge can accomodate the party

{

cout<<"Size not available in plane";

lounge.pushback(n);

lounge_size-=size ;

}

}

}

else if(n->airplane=="Bravo") //similar conditions for the second plane

{

if(Bravo_original<size)

{

cout<<"party returned back";

continue;

}

else if(Bravo<size)

{

if(lounge_size>size)

{

cout<<"Size not available in plane";

lounge.pushback(n);

lounge_size-=size ;

}

}

}

}

if(temp==3)

{

while(lounge_size!=0)

{

auto itr=lounge.begin();

while(itr!=lounge.end()) //keep flying the planes till lounge is not empty

{

if(itr->airplane="Alpha" && Alpha>size)

{

Alpha-=size;

plane.pushback(itr);

}

if(itr->airplane="Bravo" && Bravo>size)

{

Bravo-=size;

plane.pushback(itr);

}

}

fly_plane("Alpha", plane);

fly_plane("Bravo", plane);

}

}

}

}

Explanation / Answer

#include "TreeTopAir.h" #include using namespace std; void main() { Initialize(); Display_Menu(); cout
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