Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

>Build an implementation of a queue ADT. >Use this implementation to build a sim

ID: 670806 • Letter: #

Question

>Build an implementation of a queue ADT.

>Use this implementation to build a simulation of waiting queues at an airline check-in counter, organized as follows:

There are two types of passengers: first class and coach.

There are two service stations for first class and three for coach.

There is a single queue for each type of passenger (first class, coach).

Passenger arrival times are random and are generated by a random number generator.

Average arrival rates for passengers are R1 for first class and R2 for coach. These are decided at run-time by prompting the user.

Service time is random and varies uniformly between 1 and S1 for first class, and between 1 and S2 for coach. Parameters S1 and S2 are also determined at run-time, by prompting the user.

Whenever a service station is available and the corresponding queue is not empty, we pick the passenger at the front of the queue and place her/him on the service station.

Whenever a first class service station is available and the first class queue is empty, the service station may service a passenger from coach.

The duration of the experiment, in minutes, is decided by the user at run time.

Statistics generated by the simulation include: average service time, maximum service time, number served in each class, maximum queue length for each type of passenger.

Explanation / Answer

HI,

I Implemented this code in java language..Please let me know if you have any issue.

Please run airport class.

CODE:

import java.util.Scanner;
public class AirplaneQueueADT
{
int service1[]=new int[10];
int frontqueue,rearqueue;

AirplaneQueueADT()
{//constructor start..
   frontqueue=0;
   rearqueue=-1;
}//constructor ending..

void insert(int e)
{
if(rearqueue==9)
System.out.println("Queue overflow");
else
{

   service1[++rearqueue]=e;
}
}/*end insert*/


int empty()
{

return(rearqueue<frontqueue? 1:0);
}

void remove()
{/*if queue is not empty remove one element from front */
if(empty()==1)
System.out.println("Queue Underflow");
else
System.out.println("passenger gone out from queue : "+service1[frontqueue++]);
}
//to display all passengers.
void display()
{
if(empty()==0)
{
System.out.print("Queue for airplane system: ");
int t=frontqueue;//declaring front passenger.
while(t<=rearqueue)//looping through the rear passenger..
System.out.print(" "+service1[t++]);
System.out.println();

}
}

}

Airport class

CODE:

import java.util.Scanner;


public class airport
{
public static void main(String arhu[])
{
Scanner scre = new Scanner(System.in);
//construstor call for QueueADT class
AirplaneQueueADT q=new AirplaneQueueADT();
int chioi,n;
while(true)
{//while looping
System.out.println(" QUEUE");
//taking input from user
System.out.println("1.passenger Insertion into Queue");
System.out.println("2.Passenger Remove from Queue");
System.out.print("Enter your choice : ");
chioi=scre.nextInt();
//asking passenger
//switch statement to select atleast one passenger..
switch(chioi)
{
case 1:System.out.print("Enter passenger number");
n=scre.nextInt();//passenger number
q.insert(n);
q.display();
break;
case 2:q.remove();//passenger out from queue..
q.display();
break;
case 3:return;
}
}


}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote