Question
//Convert the following java program to C++ import java.util.Queue; import java.util.Scanner; import java.util.concurrent.LinkedBlockingQueue; public class AirportSimulation { public static boolean isPlaneComingIntoQueue(int avgInterval){ if(Math.random() < (1.0
//Convert the following java program to C++
import java.util.Queue; import java.util.Scanner; import java.util.concurrent.LinkedBlockingQueue;
public class AirportSimulation { public static boolean isPlaneComingIntoQueue(int avgInterval){ if(Math.random() < (1.0 / avgInterval)) return true; else return false; } public static boolean isPlaneCrashed(int in, int out, int interval){ if(out - in > interval){ return true; } else{ return false; } } public static void main(String[] args){ Scanner in = new Scanner(System.in); System.out.print("The amount of time needed for one plane to land: "); int landTime = in.nextInt(); System.out.print("the amount of time needed for one plane to take off: "); int takeoffTime = in.nextInt(); System.out.print("the average amount of time between arrival of planes to the landing queue: "); int avgArrivalInterval = in.nextInt(); System.out.print("the average amount of time between arrival of planes to the takeoff queue: "); int avgDepartureInterval = in.nextInt(); System.out.print("the maximum amount of time that a plane can stay in the landing queue without running out of fuel and crashing: "); int crashLimit = in.nextInt(); System.out.print("the total length of time to be simulated: "); int totalTime = in.nextInt(); int totalTimeSpentInLandingQueue = 0, totalTimeSpentInTakeoffQueue = 0; int numPlanesLanded = 0, numPlanesTookoff = 0; int numPlanesCrashed = 0; Queue
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started