728x90 AdSpace

Latest Article



Plane Simulation Code in c c ++ with Time





Plane  Simulation  implementation Code in  C c ++  programming language with Time

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<string.h>
#include<stdlib.h>
#include<dos.h>

struct st
{
int id;
st * ptr;
};

class simulation
{
private:
st * rear_AQ,*front_AQ;
st * rear_TQ,*front_TQ;
int sim_Time;
float avg_AQ,avg_TQ;

public:

simulation()
{
rear_AQ=NULL;
front_AQ=NULL;
rear_TQ=NULL;
front_TQ=NULL;
cout<<"Enter the simulation Time"<<endl;
cin>>sim_Time;
cout<<"Enter the average waiting Time for Arrival planes"<<endl;
cin>>avg_AQ;
cout<<"Enter the average waiting Time for TakeOff planes"<<endl;
cin>>avg_TQ;



}


void insert ( )
{

      int arrival,take,j=1,k=1;
      st * newnode;
st * p,*q;
int flag=0;

      for (int i=0;i<sim_Time;i++)
      {
arrival=random(10);
take=random(10);


if(arrival<=avg_AQ)
{

cout<<"New Arrival Plane Enters in a Queue "<<endl;
newnode=new st;
newnode->id=k;
newnode->ptr=NULL;
k++ ;

     if(rear_AQ==NULL)
{
rear_AQ=newnode;
front_AQ=newnode;
}//case 1
else
{
rear_AQ->ptr=newnode;
rear_AQ=newnode;
}

}//arrivalqueue
if(take<=avg_TQ)
{

    cout<<"New Take Off Plane Enters in a Queue "<<endl;
     newnode=new st;
     newnode->id=j;
 newnode->ptr=NULL;
     j++;

     if(rear_TQ==NULL)
{
rear_TQ=newnode;
front_TQ=newnode;
}//case 1
else
{
rear_TQ->ptr=newnode;
rear_TQ=newnode;
}

}//takequeue

delay(500);

if(front_AQ!=NULL)
{
p=front_AQ;
cout<<"Plane #"<<front_AQ->id<< "arrival has been occured"<<endl;
front_AQ=front_AQ->ptr;
delete p;
if(front_AQ==NULL)
rear_AQ=NULL;

}
   else
{
if((front_TQ!=NULL)&&(front_AQ==NULL))
{
cout<<"Run Way is empty Now"<<endl;
p=front_TQ;
cout<<"Plane #"<<front_TQ->id<< "Take off has been occured"<<endl;
front_TQ=front_TQ->ptr;
delete p;
if(front_TQ==NULL)
rear_TQ=NULL;
}
}//for take off
delay(500);

  }//for loop

while(front_AQ!=NULL)
{  
p=front_AQ;
cout<<"Plane #"<<front_AQ->id<< "arrival has been occured"<<endl;
front_AQ=front_AQ->ptr;
delete p;
   delay(1000);
}
      if(front_AQ==NULL)
{
rear_AQ=NULL;
cout<<"Run way is Empty "<<endl;
while(front_TQ!=NULL)
{      
p=front_TQ;
cout<<"Plane #"<<front_TQ->id<< "Take off has been occured"<<endl;
front_TQ=front_TQ->ptr;
delete p;
delay(1000);
}
rear_TQ=NULL;

} //end of if


}
};
void main()
{
 ` clrscr();
simulation l;
l.insert();
getche();
}

no image
  • Title : Plane Simulation Code in c c ++ with Time
  • Posted by :
  • Date : 04:11
  • Labels :






  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment