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

C++ ASSIGNMENT:Your employer has determined a market for a simple airline ticket

ID: 3705277 • Letter: C

Question

C++ ASSIGNMENT: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 returnof the planethe 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 arethe following:ALFA<size>BRAVO<size>LOUNGE<size>FLY<airplane>ARRIVE<airplane> <party> <size>SHUTDOWNwhere:<airplane> is either ALFA or BRAVO.<party> is a name of unlimited length.<size> is an integer numberFields in the input will be separated by some amount of whitespace.The ticket clerk is a terrible typist.
NOTES: Use “C-type” strings (arrays of characters). You may not use classes or strings.

Explanation / Answer

// Airlines.cpp : Defines the entry point for the console application,

//

#include "stdafx.h"

#include<iostream>

#include<string>

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 partySize;

bool flightAlfa=true;

bool flightAReturn=false,flightBReturn=false;

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

cout<<"===================================="<<endl;

cout<<"Alfa";

cin>>Lsize1;

Lsize1Left=Lsize1;

cout<<"BRAVO";

cin>>Lsize2;

Lsize2Left=Lsize2;

cout<<endl;

cout<<"LoungeA";

cin>>loungeA;

cout<<"LoungeB";

cin>>loungeB;

cout<<endl;

do

{

{

cout<<"FLY";

cin>>flightChoice;

if(flightChoice=="Alfa")

{

flightA(Lsize1,passengerList1,iLsize1Left,loungeA);

}

else if(flightChoice=="Bravo")

{

flightB(Lsize2,passengerList2j,Lsize2Left,loungeB);

}

else

{

cout<<"Incorrect flight choice";

exit(0);

}

}while(flightChoice!="N");

cout<<endl;

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 passengerList1[ ],int i,int Lsize1Left, int loungeA)

{

int partySize=0;

cout<<"Enter party name:";

cin>>partySize;

if(partySize>Lsize1)

cout<<"Flight is full.";

else if(partSize>Lsize1Left)

{

if(partySize<loungeA)

{

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 journey!";

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>Lsize2)

cout<<"Flight is full.";

else if(partySize>Lsize2Left)

{

if(partySize<loungeB)

{

cout<<"Please wait in the lounge";

loungeB-=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 journey!";

Lsize2Left-=partySize;

}

fly("Alfa", Lsize2Left, Lsize2, passengerList2);

}

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

{

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

{

if(flightChoice=="Alfa")

cout<<"Alfa Flight ready to fly";

else

cout<<"Bravo Flight ready to fly";

cout<<"Passenger List:";

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

{

cout<<passengerList[i];

}

}

else

cout<<"Flying as per clerk entery";

}

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

{

if(lounge>0)

{

if(lounge<Lsize)

{

LsizeLeft=Lsize-lounge;

lounge=0;

//fly(flightChoice,LsizeLeft,Lsize,passengerList);

}

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

}

lounge-=Lsize;

LsizeLeft=0;

fly(flightChoice,LsizeLeft,Lsize,passengerList);

}

else

{

}

}

else

{

cout<<"Flight available";

}

}

Output:

Welcome to Tree Top Airways(TTA)

==================================

Alfa125

BRAVO125

LoungeA70

LoungeB50

FLYBravo

Enter party name:sam

Enter passenger size23

Your booking is confirmed! Have a safe journey!Flying as per clerk enteryFLYAlfa

Enter party name:eva

Enter passenger size150

Flight is full. Flying as per clerk enteryFLYn