hi i am a fourth year computing major and i need some help with the following assignment. The program is to simulate the operation of one day's activity at an airport, and output the times waiting to land and take off for each BWIA flight. the program should include the following as input data :
1. the number of avaliable runways
2. the average time a runway is in use for an arrival
3. the average time a runway is in use for a departure
4. the average number of BWIA arrivals eah hour
5. the average number of other airline arrivals each hour.
6. the average number of BWIA departures each hour.
7. the average number of other airline departures each hour.

# include <iostream.h> 
# include <iomanip.h>

# include " queue.h" 

RandomGenerator generator; 

int 
random(); 

void main( )
{
   double dpt_time,arr_time,bwia_dpt,bwia_arr,runways,other_arr,other_dpt

queue<int> " enter departure time:";
cin>> dpt_time;
cout<< " enter time runway is in use for arrivals:";
cin>> arr_time;
cout<< " enter number of bwia arrivals per hour:";
cin>> bwia_dpt;
cout<< " enter number of bwia departures per hour:";
cin>> bwia_arr;
cout<< "  enter number of other arrivals  per hour:";
cin>>other_arr;
cout<<" enter number of departures per hour:";
cin>>other _dpt;
cout<< " enter number of runways:";
cin>> runways;

initalize members to 0
for (minute = 1; minute <= 60; ++ minute)
{
if (random () < runways)

and this is as i far as i got , please help me.

given the current state of BWIA you could set the date into the future and output 0 for every category as they're almost bankrupt :)

What output will you need? How complex does the calculation need to be?
If you want it truly realistic the number of factors is so mindboggling it can take a supercomputer to calculate it all and a team of hundreds to create the software.

Do you have to account for parallel runway operations or not?
Weather conditions, taxiway congestion, etc. etc.

your post is in violation of the terms of service and has been reported as such.
Plus by doing peoples' homework for them you're doing the entire IT industry a massive disservice by lowering the quality of programmers entering the industry (or rather you're helping people enter the industry as programmers who don't know the first thing about programming, thus increasing the workload of people who do know while decreasing the appreciation others have of us).

your post is in violation of the terms of service and has been reported as such.
Plus by doing peoples' homework for them you're doing the entire IT industry a massive disservice by lowering the quality of programmers entering the industry (or rather you're helping people enter the industry as programmers who don't know the first thing about programming, thus increasing the workload of people who do know while decreasing the appreciation others have of us).

My sentiments exactly. User banned, posts deleted, within guidelines of Daniweb.

stacia, would you be interested in buying the code :D P.S. I don't think that you're a forth year student :)

#include <iostream>
#include <iomanip>
#include <stdlib.h>
using namespace std;

//typedef double Node_entry;

typedef double Queue_entry;

enum Error_code {success,overflow,underflow};

void initialize(int &end_time, int &queue_limit, int &arrival_rate, int &departure_rate)
/*
Pre:  The user specifies the number of time units in the simulation,
      the maximal queue sizes permitted,
      and the expected arrival and departure rates for the airport.
Post: The program prints instructions and initializes the parameters
      end_time, queue_limit, arrival_rate, and departure_rate to
      the specified values.
Uses: utility function user_says_yes
*/

{
   cout << "This program simulates an airport with only one runway." << endl
        << "One plane can land or depart in each unit of time." << endl;
   cout << "Up to what number of planes can be waiting to land "
        << "or take off at any time? " << flush;
   cin  >> queue_limit;

   cout << "How many units of time will the simulation run?" << flush;
   cin  >> end_time;

   bool acceptable;
   do {
      cout << "Expected number of arrivals per unit time?" << flush;
      cin  >> arrival_rate;
      cout << "Expected number of departures per unit time?" << flush;
      cin  >> departure_rate;
      if (arrival_rate < 0.0 || departure_rate < 0.0)
         cerr << "These rates must be nonnegative." << endl;
      else
         acceptable = true;

      if (acceptable && arrival_rate + departure_rate > 1.0)
         cerr << "Safety Warning: This airport will become saturated. " << endl;

   } while (!acceptable);
}

/* ---------------------------------- Plane ------------------------------- */

enum Plane_status {null, arriving, departing};

class Plane 
{
   int flt_num;
   int clock_start;
   Plane_status state;

public:
   Plane();
   Plane(int flt, int time, Plane_status status);
   void refuse() ;
   void land(int time) ;
   void fly(int time) ;
   int started();

};

Plane::Plane(int flt, int time, Plane_status status)
/*
Post:  The Plane data members flt_num, clock_start,
       and state are set to the values of the parameters flt,
       time and status, respectively.
*/
{
   flt_num = flt;
   clock_start = time;
   state = status;
   cout << "Plane number " << flt << " ready to ";
   if (status == arriving)
      cout << "land." << endl;
   else if (status == departing)
      cout << "take off." << endl;
}

Plane::Plane(){
   flt_num = -1;
   clock_start = -1;
   state = null;
}

void Plane::refuse()
/*
Post: Processes a Plane wanting to use Runway, when
      the Queue is full.
*/
{
   cout << "Plane number " << flt_num;
   if (state == arriving)
      cout << " directed to another airport" << endl;
   else
      cout << " told to try to takeoff again later" << endl;
}


void Plane::land(int time) 
/*
Post: Processes a Plane that is landing at the specified time.
*/
{
   int wait = time - clock_start;
   cout << time << ": Plane number " << flt_num << " landed after "
        << wait << " time unit" << ((wait == 1) ? "" : "s")
        << " in the takeoff queue." << endl;
}


void Plane::fly(int time) 
/*
Post: Process a Plane that is taking off at the specified time.
*/

{
   int wait = time - clock_start;
   cout << time << ": Plane number " << flt_num << " took off after "
        << wait << " time unit" << ((wait == 1) ? "" : "s")
        << " in the takeoff queue." << endl;
}


int Plane::started()
/*
Post: Return the time that the Plane entered the airport system.
*/
{
   return clock_start;
}


/* -------------------------------- End Plane ----------------------------- */

struct Node {
    // data members
    Plane entry;
    Node *next;
    Node(){next = NULL;};         
	// constructors
    Node(Plane item, Node *add_on = NULL){entry = item; next = add_on; };
};

/* --------------------------------- An implementation for a queue ------------------------- */

class Queue 
{
	Node *front,*rear;
public:

    Queue(){ front = rear = NULL; };
    void clear(){ while(!empty()) serve(); };
    bool empty(){ return front == NULL; };
    bool full() const;
    int size() const;
    Error_code retrieve(Plane &item) ;
    Error_code serve();
    Error_code append(const Plane &item);
    ~Queue(){ while (!empty()) serve(); };
    Queue(const Queue &original);
    void operator=(const Queue &original);
};
//-----------------------------------------------------------------------------------------//

int Queue::size() const
{
    int count = 0;
    Node *temp = front;
    while (temp!=NULL)
    {
        count++;
        temp = temp->next;
    }
    return count;
}

Error_code Queue::retrieve(Plane &item)
{
    if (empty()) 
		return underflow;
	item = front->entry;
    return success;
}

Error_code Queue::serve()
{
    if (empty()) 
		return underflow;
	
	Node *old_front = front;
    front = front->next;

    if (front==NULL) 
		rear = NULL;

    delete old_front;
    return success;
}

Error_code Queue::append(const Plane &item)
{
    Node *new_rear = new Node(item);

    if (new_rear==NULL) 
		return overflow;  // FULL

    if (rear==NULL) 
		front = rear = new_rear;
    else
    {
        rear->next = new_rear;
        rear = new_rear;
    }

    return success;
}

Queue::Queue(const Queue &original)
{
    Node *new_copy, *original_node = original.front;

    if (original_node == NULL)
		front = rear = NULL;
    else
    {
        front = new_copy = new Node(original_node->entry);
        while (original_node->next != NULL)
        {
            original_node = original_node->next;
            new_copy->next = new Node(original_node->entry);
            new_copy = new_copy->next;
            rear = new_copy;
        }
    }
}

void Queue::operator=(const Queue &original)

{

    Node *new_front,*new_rear,*new_copy, *original_node = original.front;

    if (original_node == NULL)
		new_front = new_rear = NULL;
    else
    {
        new_copy = new_front = new_rear = new Node(original_node->entry);
        while (original_node->next != NULL)
        {
            original_node = original_node->next;
            new_copy->next = new Node(original_node->entry);
            new_copy = new_copy->next;
            new_rear = new_copy;
        }
    }

    while (!empty())
		serve();

    front = new_front;
    rear = new_rear;

}
/* --------------------------- End of Queue implementation ---------------- */


/* ----------------------------------The Runway---------------------------- */
enum Runway_activity {idle, land, takeoffg};

class Runway {
public:
   Runway(int limit);
   Error_code can_land(const Plane &current);
   Error_code can_depart(const Plane &current);
   Runway_activity activity(int time, Plane &moving);
   void shut_down(int time);

private:
   Queue landing;
   Queue takeoff;
   int queue_limit;
   int num_land_requests;        //  number of planes asking to land
   int num_takeoff_requests;     //  number of planes asking to take off
   int num_landings;             //  number of planes that have landed
   int num_takeoffs;             //  number of planes that have taken off
   int num_land_accepted;        //  number of planes queued to land
   int num_takeoff_accepted;     //  number of planes queued to take off
   int num_land_refused;         //  number of landing planes refused
   int num_takeoff_refused;      //  number of departing planes refused
   int land_wait;                //  total time of planes waiting to land
   int takeoff_wait;             //  total time of planes waiting to take off
   int idle_time;                //  total time runway is idle
};

Runway::Runway(int limit)
/*
Post:  The Runway data members are initialized to record no
       prior Runway use and to record the limit on queue sizes.
*/

{
   queue_limit = limit;
   num_land_requests = num_takeoff_requests = 0;
   num_landings = num_takeoffs = 0;
   num_land_refused = num_takeoff_refused = 0;
   num_land_accepted = num_takeoff_accepted = 0;
   land_wait = takeoff_wait = idle_time = 0;
}


Error_code Runway::can_land(const Plane &current)
/*
Post:  If possible, the Plane current is added to the
       landing Queue; otherwise, an Error_code of overflow is
       returned. The Runway statistics are updated.
Uses:  class Extended_queue.
*/
{
   Error_code result;
   if (landing.size() < queue_limit)
      result = landing.append(current);
   else
      result = overflow;

   num_land_requests++;

   if (result != success)
      num_land_refused++;
   else
      num_land_accepted++;

   return result;
}


Error_code Runway::can_depart(const Plane &current)
/*
Post:  If possible, the Plane current is added to the
       takeoff Queue; otherwise, an Error_code of overflow is
       returned. The Runway statistics are updated.
Uses:  class Extended_queue.
*/

{
   Error_code result;
   if (takeoff.size() < queue_limit)
      result = takeoff.append(current);
   else
      result = overflow;
   num_takeoff_requests++;
   if (result != success)
      num_takeoff_refused++;
   else
      num_takeoff_accepted++;

   return result;
}


Runway_activity Runway::activity(int time, Plane &moving)
/*
Post:  If the landing Queue has entries, its front
       Plane is copied to the parameter moving
       and a result  land is returned. Otherwise,
       if the takeoff Queue has entries, its front
       Plane is copied to the parameter moving
       and a result  takeoff is returned. Otherwise,
       idle is returned. Runway statistics are updated.
Uses:  class Extended_queue.
*/

{
   Runway_activity in_progress;
   if (!landing.empty()) {
      landing.retrieve(moving);
      land_wait = land_wait + time - moving.started();
      num_landings++;
      in_progress = land;
      landing.serve();
   }

   else if (!takeoff.empty()) {
      takeoff.retrieve(moving);
      takeoff_wait += time - moving.started();
      num_takeoffs++;

      in_progress = takeoffg;
      takeoff.serve();
   }

   else {
      idle_time++;
      in_progress = idle;
   }
   return in_progress;
}


void run_idle(int time)
/*
Post: The specified time is printed with a message that the runway is idle.
*/
{
   cout << time << ": Runway is idle." << endl;
}


void Runway::shut_down(int time)
/*
Post: Runway usage statistics are summarized and printed.
*/

{
   cout << "Simulation has concluded after " << time << " time units." << endl;
   cout << "Total number of planes processed " << (num_land_requests + num_takeoff_requests) << endl;
   cout << "Total number of planes asking to land " << num_land_requests << endl;
   cout << "Total number of planes asking to take off " << num_takeoff_requests << endl;
   cout << "Total number of planes accepted for landing " << num_land_accepted << endl;
   cout << "Total number of planes accepted for takeoff " << num_takeoff_accepted << endl;
   cout << "Total number of planes refused for landing " << num_land_refused << endl;
   cout << "Total number of planes refused for takeoff " << num_takeoff_refused << endl;
   cout << "Total number of planes that landed " << num_landings << endl;
   cout << "Total number of planes that took off "<< num_takeoffs << endl;
   cout << "Total number of planes left in landing queue " << landing.size() << endl;
   cout << "Total number of planes left in takeoff queue " << takeoff.size() << endl;
   cout << "Percentage of time runway idle "
        << 100.0 * (( float ) idle_time) / (( float ) time) << "%" << endl;
   cout << "Average wait in landing queue "
        << (( float ) land_wait) / (( float ) num_landings) << " time units";
   cout << endl << "Average wait in takeoff queue "
        << (( float ) takeoff_wait) / (( float ) num_takeoffs)
        << " time units" << endl;
   cout << "Average observed rate of planes wanting to land "
        << (( float ) num_land_requests) / (( float ) time)
        << " per time unit" << endl;
   cout << "Average observed rate of planes wanting to take off "
        << (( float ) num_takeoff_requests) / (( float ) time)
        << " per time unit" << endl;
}

/* ---------------- End of Runway ----------------------------------------- */

class Random
{
	
public:
	int poisson(int arrival_rate)
	{
		int no = rand()%arrival_rate;
		return no;
	};
};



int main()     //  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.
*/
{
   int end_time=0;            //  time to run simulation
   int queue_limit=0;         //  size of Runway queues
   int flight_number = 0;
   int arrival_rate=0, departure_rate=0;
   initialize(end_time, queue_limit, arrival_rate, departure_rate);
   Random variable;
   Runway small_airport(queue_limit);

   for (int current_time = 0; current_time < end_time; current_time++) 
   { 
      int number_arrivals = variable.poisson(arrival_rate);  //  current arrival requests
      for (int i = 0; i < number_arrivals; i++) 
	  {
         Plane current_plane(flight_number++, current_time, arriving);
         if (small_airport.can_land(current_plane) != success)
            current_plane.refuse();
      }

      int number_departures= variable.poisson(departure_rate); //  current departure requests
      for (int j = 0; j < number_departures; j++) 
	  {
         Plane current_plane(flight_number++, current_time, departing);
         if (small_airport.can_depart(current_plane) != success)
            current_plane.refuse();
      }

      Plane moving_plane;
      switch (small_airport.activity(current_time, moving_plane)) 
	  {
        //  Let at most one Plane onto the Runway at current_time.
      case land:
         moving_plane.land(current_time);
         break;
      case takeoffg:
         moving_plane.fly(current_time);
         break;
      case idle:
         run_idle(current_time);
     }
   }
   small_airport.shut_down(end_time);
   return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.