Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions