943,865 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 751
  • C++ RSS
Jan 12th, 2009
0

Re: Need Help in Writing An Airport simulation program.

Expand Post »
Click to Expand / Collapse  Quote originally posted by ArkM ...
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:
Similar Threads
Reputation Points: 7
Solved Threads: 0
Newbie Poster
david7 is offline Offline
2 posts
since Jan 2009
Jan 12th, 2009
-1

Re: Need Help in Writing An Airport simulation program.

i need it in two days
Reputation Points: 7
Solved Threads: 0
Newbie Poster
david7 is offline Offline
2 posts
since Jan 2009
Jan 12th, 2009
0

Re: another do my homework for me thread

Hurry up!!!
Reputation Points: 395
Solved Threads: 71
Posting Whiz
jencas is offline Offline
362 posts
since Dec 2007
Jan 12th, 2009
1

Re: another do my homework for me thread

Man, u gon pay money to ppl for doin ya homework or what?
Reputation Points: 36
Solved Threads: 5
Newbie Poster
da penguin is offline Offline
18 posts
since Dec 2008
Jan 12th, 2009
0

Re: another do my homework for me thread

How 'bout you hurry up and get me my code....PLZ PPLZ!
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jan 12th, 2009
0

Re: another do my homework for me thread

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...
Reputation Points: 2035
Solved Threads: 644
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008
Jan 12th, 2009
2

Re: another do my homework for me thread

Is there a way to remove these threads altogether? It really pollutes the forums.

Dave
Featured Poster
Reputation Points: 437
Solved Threads: 204
Posting Virtuoso
daviddoria is offline Offline
1,968 posts
since Feb 2008
Jan 12th, 2009
1

Re: another do my homework for me thread

Quote originally posted by Douglas Adams ...
http://www.quotationspage.com/quote/22644.html
I love deadlines. I love the whooshing sound they make as they fly by.
.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Jan 12th, 2009
0

Re: another do my homework for me thread

C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. int main(void){
  8. int hours = 36;
  9. int mins = 57;
  10. int secs = 58;
  11. while(1){
  12. system("cls");
  13. if(hours > 0 || mins > 0 || secs > 0){
  14. cout << "Deadline in: " << hours << "h" << mins << "m" << secs << "s";
  15. if(mins == 0){
  16. if(hours != 0){
  17. mins = 59;
  18. hours -= 1;
  19. }
  20. }
  21. if(secs == 0){
  22. if(mins != 0){
  23. secs = 59;
  24. mins -= 1;
  25. }else{
  26. if(hours != 0){
  27. hours -=1;
  28. mins = 59;
  29. secs = 59;
  30. }
  31. }
  32. }else secs -= 1;
  33. Sleep(CLOCKS_PER_SEC-30);
  34. }else break;
  35. }
  36. system("cls");
  37. cout << "Assignment Due!!!!";
  38. cin.get();
  39. return 0;
  40. }
Last edited by Freaky_Chris; Jan 12th, 2009 at 7:00 pm.
Reputation Points: 325
Solved Threads: 118
Master Poster
Freaky_Chris is offline Offline
702 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: apache xml parser for c++
Next Thread in C++ Forum Timeline: Sorting link list as append





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC