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 simul

ID: 670135 • Letter: B

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

import java.io.*;
import java.util.*;

class first_class{
   ArrayList<passenger> pass;
   boolean status;
   passenger p_in_service;
   public first_class(String s){
       pass = new ArrayList<passenger>();
       status = false;
   }
   void assign_service(coach_class c){
       if (status == false){
           if (this.pass.size() == 0){
               p_in_service = c.pass.front();          
               status = true;
           }
           else{
               p_in_service = this.pass.front();
               status = true;
           }
       }
   }
}

class coach_class{
   ArrayList<passenger> pass;
   boolean status;
   public coach_class(String s){
       pass = new ArrayList<passenger>();
       status = false;
   }  
}

class passenger{
   String name;
   String class;
   int arrival_time;
   public passenger(String n,int a,String c){
       name = n;
       a = arrival_time;
       class = c;
   }
}

class main{
   public static void main(String[] args){

   }
}

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