Question: I need help with an assignment. As a specific example, let us consider a small but busy airport with only one runway study (see Figure
I need help with an assignment.
As a specific example, let us consider a small but busy airport with only one runway study (see Figure 3.5). In each unit of time, one plane can land or one plane can take off, but not both. Planes arrive ready to land or to take off at random times, so at any given moment of time, the runway may be idle or a plane may be landing or taking off, and there may be several planes waiting either to land or take off. represent individual planes. We shall need one other class in our simulation, a class Random to encapsulate the random nature of plane arrivals and departures from the runway. We shall discuss this class in more detail in Section 3.5.3. In our main program, we use a
single method, called poison, from the class Random. This method uses a floating- point parameter (representing an average outcome) and it returns an integer value. Although the returned value is random, it has the property that over the course of many repeated method calls, the average of the returned values will match our specified parameter. In our simulation, we shall be especially concerned with the amount of time that planes need to wait in queues before taking off or landing. Therefore, the measurement of time will be of utmost importance to our program. We shall divide the time period of our simulation into units in such a way that just one plane can use the runway, either to land or take off, in any given unit of time. The precise details of how we handle the landing and takeoff queues will be dealt with when we program the Runway class. Similarly, the precise methods describing the operation of a Plane are not needed by our main program.
















int main() 1/ Airport simulation program /* Pre: The user must supply the number of time intervals the simulation is to run the expected number of planes arriving, the expected number of planes departing per time interval, and the maximum allowed size for runway queues. Post: The program performs a random simulation of the airport, showing the status of the runway at each time interval, and prints out a summary of airport operation at the conclusion. Uses: Classes Runway, Plane, Random and functions run_idle, initialize. */ 98 Chapter 3 . Queues int end_time; 11 time to run simulation int queue_limit; 11 size of Runway queues int flight_number = 0; double arrival_rate, departure_rate; initialize(end_time, queue_limit, arrival_rate, departure_rate); Random variable; Runway small_airport(queue_limit); for (int current_time = 0; current_time > queue_limit; cout > end_time; bool acceptable; do { cout > arrival_rate; cout > departure_rate; if (arrival_rate 1.0) cerr
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
