You need to simulate the working of an airport using a C program.
Let us consider a small but busy airport with three runways, one always reserved for landing, one for takeoff and the third used for landings unless the landing queue is empty, in which case it can be used for takeoffs. Planes arrive ready to land or ready to take off at random times, so at any given unit of time, the runways 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. The simulation should run through many units of time
Answers
Answered by
1
- Algorithm
- Create two queues, landing and takeoff
- Initialize statistics counters to zero
- Loop for time unit from 1 to some fixed number
- Loop from 1 to some random number of landing planes
- If landing queue is not full, add plane to the queue else
- refuse landing and increment number of refused.
- Loop from 1 to some random number of taking off planes
- If takeoff queue is not full, add plane to the queue else
- refuse landing and increment number of refused.
- If landing queue is not empty process next landing plane and
- increment count of planes landed
- Else if takeoff queue is not empty, process next plane and increment count of take off planes
- Else increment count of run-way idle time.
- Print the statistics.
Please find attached .txt file which contain source code.
Attachments:
Similar questions