You are welcome!

Simulation of an Airport Runway

An airport is developing a computer simulation of air-traffic control, which handles events such as landings and take-offs. It is a small busy airport with only one runway. 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 unit of time, the runway may be idle or a plane may be landing or taking off. There may be several planes waiting either to land or to take off. Follow the steps given below to design the program.

1. Create two queues one for the planes landing and the other for planes taking off.

2. Get the maximum number of units <endtime> for which the simulation program would run.

3. Get the expected number of planes arriving in one unit <expectarrive> and number of planes ready to take off in one unit <expectdepart>.

4. To display the statistical data concerning the simulation, declare following data members.

a) idletime - to store the number of units the runway was idle

b) landwait - to store total waiting time required for planes landed

c) nland - to store number of planes landed

d) nplanes - to store number of planes processed

e) nrefuse - to store number of planes refused to land on airport

f) ntakeoff - to store number of planes taken off

g) takeoffwait - to store total waiting time taken for take off

Initialize the queue used for the plane landing and for the take off

Get the data for <endtime>, <expectarrive> and <expectdepart> from the user.

The process of simulation would run for many units of time, hence run a loop in main() that would run from <curtime> to <endtime> where <curtime> would be 1 and <endtime> would be the maximum number of units the program has to be run.

Generate a random number. Depending on the value of random number generated, perform following tasks.

1. If the random number is less than or equal to 1 then get data for the plane ready to land. Check whether or not the queue for landing of planes is full. If the queue is full then refuse the plane to land. If the queue is not empty then add the data to the queue maintained for planes landing.

2. If the random number generated is zero, then generate a random number again. Check if this number is less than or equal to 1. If it is, then get data for the plane ready to take off. Check whether or not the queue for taking a plane off is full. If the queue is full then refuse the plane to take off otherwise add the data to the queue maintained for planes taking off.

3. It is better to keep a plane waiting on the ground than in the air, hence allow a plane to take off only, if there are no planes waiting to land.

4. After receiving a request from new plane to land or take off, check the queue of planes waiting to land, and only if the landing queue is empty, allow a plane to take off.

5. If the queue for planes landing is not empty then remove the data of plane in the queue else run the procedure to land the plane.

6. Similarly, if the queue for planes taking off is not empty then remove the data of plane in the queue else run the procedure to take off the plane.

7. If both the queues are empty then the runway would be idle.

8. Finally, display the statistical data as given below.

Total number of planes processed

Number of planes landed:

Number of planes taken off:

Number of planes refused use:

Number of planes left ready to land:

Number of planes left ready to take off:

Percentage of time the runway was idle:

Average waits time to land:

Average waits time to take off:

Man, u gon pay money to ppl for doin ya homework or what?

Comments
Nice avatar, I watched BB again last weekend - classic!

Well thank you!
I like programming as a hobby and you have given me a nice project to work on!
Let you know when it's finished but it certainly won't be in two days.
Deadlines, man how I hated those deadlines when I was still programming professionally...

#include <iostream>
#include <windows.h>
#include <ctime>

using namespace std;

int main(void){
    int hours = 36;
    int mins = 57;
    int secs = 58;
    while(1){
        system("cls");
        if(hours > 0 || mins > 0 || secs > 0){
            cout << "Deadline in: " << hours << "h" << mins << "m" << secs << "s";
            if(mins == 0){
                if(hours != 0){
                    mins = 59;
                    hours -= 1;
                }
            }
            if(secs == 0){
                if(mins != 0){
                    secs = 59;
                    mins -= 1;
                }else{
                    if(hours != 0){
                        hours -=1;
                        mins = 59;
                        secs = 59;
                    }
                }
            }else secs -= 1;
            Sleep(CLOCKS_PER_SEC-30);
        }else break;
    }
    system("cls");
    cout << "Assignment Due!!!!";
    cin.get();
    return 0;
}
This article has been dead for over six months. Start a new discussion instead.