Question
Use your queue implementation to simulate a bank with 3 tellers and one line. The time between arrival of customers is a random integer between
Use your queue implementation to simulate a bank with 3 tellers and one line. The time between arrival of customers is a random integer between 1 and 5. When a customer arrives, the customer gets in line. When any of the three tellers is available, the first customer in line goes to that teller. The time to process that customers transaction is another random integer between 1 and 5. When the transaction is completed, the customer leaves. Run the simulation for 100 customers. Report the average time the customer waits in the queue.
Queue.java////
public class Queue { public int head; public int tail; public int size; public int[] Q; public Queue(int size) { this.head = 1; this.tail = 1; this.Q = new int[size]; } public boolean isEmpty() { if(this.tail == this.head) return true; return false; } public boolean isFull() { if(this.head == this.tail+1) return true; return false; } public void enqueue(int x) { if(isFull()) { System.out.println("Queue Overflow"); } else { this.Q[this.tail] = x; if(this.tail == this.size) this.tail = 1; else this.tail = this.tail+1; } } public int dequeue() { if(isEmpty()) { System.out.println("Underflow"); return -1000; } else { int x = this.Q[this.head]; if(this.head == this.size) { this.head = 1; } else { this.head = this.head+1; } return x; } } public void display() { int i; for(i=this.head; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started