Answer to Question #264982 in C++ for Ahsan wains

Question #264982

You will be simulating an airport where 8 planes go out on tours repeatedly. Each tour will be for exactly 12 passengers and last approximately 30 seconds. In performing the simulation, you must make sure that no plane tries to leave a gate with less (or more) than 12 passengers

and that no plane lands or takes off at the same time as another plane is landing or taking off.

The first thing your program should do is read the following from the command line (in the

order specified):

1.Try running your program with only 11 passengers. What happens? Why?

2. Try running your program with 12 passengers. What happens? Why?

3. Try running your program with 50 passengers and 100 tours. What happens? why?

4. Try running your program with 100 passengers and 20 tours. What happens? Why?

5. What is the minimum number of passengers that will guarantee avoidance of

deadlock? Why?


1
Expert's answer
2021-11-13T23:53:25-0500


SOLUTION TO THE ABOVE QUESTION


SOLUTION CODE


#include<iostream>
using namespace std;
int main()
{
 int number_of_passengers;
 cout<<"\nEnter the total passangers on the airport: ";
 cin>>number_of_passengers;
 int tours;
 cout<<"\nEnter the total number of tours that the planes should take: ";
 cin>>tours;
 //Now let us code the constraints
 //1.No plane should take of with less than 12 passengers


 if(number_of_passengers < 12)
 {
 	cout<<"\nThe plane can't take of with less than 12 passengers, your plane has "<<number_of_passengers<<" passengers."<<endl;
 }
 else if(number_of_passengers==12)
 {
 	cout<<"\nThe plane has successfully took off for a tour,it has 12 passengers"<<endl;
 }
 else if(tours>(number_of_passengers/8))
 {
 	cout<<"You have "<<number_of_passengers<<" passengers and are not enough for "<<tours<<" tours"<<endl;
 }
 else
 {
 	cout<<"Your passengers are "<<number_of_passengers<<" and can tours planes will make are "<<tours<<endl;
 }


}


SAMPLE PROGRAM OUTPUT






Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS