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

Question is in the picture below. There are two pages, on first page its explain

ID: 3546204 • Letter: Q

Question

Question is in the picture below. There are two pages, on first page its explaining what's this program is about and on second page how to implement the program. PLEASE provide all the method ask in question below in the picture.

(And yea I m gonna offer 3000 points but the only option i m getting right now is 1500 points max, And when i m trying to add more points this pictures getting disappear and i cant upload it back( I had this problem like so many time) so once any one saves the picture and let me know by comment that you are answering then ill edit the question and add more 1500 points so its gonna be 3000 points plus 5 star rating for sure. Thank you )

Suppose that college Airport has one runway, which each airplane takes landing Time minutes to land take off Time minutes to take off, and that on the average, take off Rate planes take off and landing Rate planes land each hour. Assume that the planes arrive at random instants of time. Delays make the assumption of randomness quite reasonable. Write a Java program to simulate Airport's operation. You might assume a simulated clock that advances in one-minute intervals. For each minute, generate 2 random numbers. If the first is less than landingRate/60, a "landing arrival" has occurred and is added to the landing queue; and if the second is less than takeOffRate/60, a "takeoff arrival" has occurred and is added to the takeoff queue. Next, check whether the runway is free. If it is free, first check whether the landing queue is nonempty, and if so, allow the first airplane to land; otherwise consider the takeoff queue. Have the program calculate the average queue length and the average time that an airplane spends in a queue. You should also consider the effect of varying arrival and departure rates to simulate the prime and slack Times of day, or what happens if the amount of time to land or take off is increased or decreased.

Explanation / Answer

please rate


public class ArrayQueue<T> {
   
    private final T[] array;
    private int top;
    private int capacity = 1000;
       
    @SuppressWarnings("unchecked")
    public ArrayQueue(int capacity) {
         array=(T[])new Object[capacity];
    }
   
    @SuppressWarnings("unchecked")
    public ArrayQueue(){
        array=(T[])new Object[capacity];       
    }
   

    public boolean isEmpty(){
        if (top==0)
            return true;
        return false;
    }
   
    public int count(){
        return top;
    }
   
    public T peek(){
        return array[top];
    }
   
    public T dequeue(){
        if(!isEmpty()){           
            return array[top--];
        }
        return null;
           
    }
   
    public void enqueue(T t){
        if (top!=capacity){
            array[++top] = t;
        }else{
            System.err.println("Queue is full");
        }
    }

}



public class Airport {
    final double LANDING_TIME = 3;
    final double TAKE_OFF_TIME = 2;
    final double LANDING_RATE = 10;
    final double TAKE_OFF_RATE = 10;
    final int ITERATIONS = 1440;
   
    ArrayQueue<Integer> landingQ;
    ArrayQueue<Integer> takeOffQ;
   
    private double avg_landq_length = 0;
    private double avg_takeoffq_length = 0;
    private double avg_time_on_landQ = 0;
    private double avg_time_on_takeoffQ = 0;
   
    // null for runway indicates that it is free
    private Integer runway = null;
   
    public Airport(){       
        landingQ = new ArrayQueue<>();
        takeOffQ = new ArrayQueue<Integer>();
        for(int i=0;i<ITERATIONS;i++){
            simulate();
        }
        avg_time_on_landQ = avg_landq_length * LANDING_TIME / ITERATIONS;
        avg_time_on_takeoffQ = avg_takeoffq_length * TAKE_OFF_TIME / ITERATIONS;
        avg_landq_length /= ITERATIONS;
        avg_takeoffq_length /= ITERATIONS;
        System.out.println("Average landing queue length: "+avg_landq_length);
        System.out.println("Average take off queue length: "+avg_takeoffq_length);
        System.out.println("Average landing queue time: "+avg_time_on_landQ);
        System.out.println("Average takeoff queue time: "+avg_time_on_takeoffQ);
    }
   
    Random generator = new Random(System.currentTimeMillis());
   
    public void simulate(){
        double land = generator.nextDouble();
        double takeOff = generator.nextDouble();
        if(land<LANDING_RATE/60){
            landingQ.enqueue((int) land);
            System.out.println("takeoff");
        }
        if(takeOff<TAKE_OFF_RATE/60){
            takeOffQ.enqueue((int) takeOff);
            System.out.println("landed");
        }
        if(runway==null){
            // runway is free so now
            // Checking if landing queue is empty
            if (!landingQ.isEmpty()){
                // Allow it to land
                runway = landingQ.dequeue();
            } else if (!takeOffQ.isEmpty()) {
                // Allow to take off
                runway = takeOffQ.dequeue();
            }
        } else {
            runway = null;
        }
        avg_landq_length += landingQ.count();
        //System.out.println("Land q count "+avg_landq_length);
        avg_takeoffq_length += takeOffQ.count();   
    }
    public static void main(String[] args){
        new Airport();
    }
   
   
}


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