Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write two classes and a driver program using a java.util class such as LinkedList that implements the Queue interface with its insert() (enqueue), remove() (dequeue)

Write two classes and a driver program using a java.util class such as LinkedList that implements the Queue interface with its insert() (enqueue), remove() (dequeue) and element() (peek) methods to simulate a line at a bank. The basic idea is to use a "clock" which is simply a loop that counts seconds for simulation, not real seconds, so each time through the loop will simulate one second.

The Customer class

has a one-int-parameter constructor that takes the current clock time as an integer parameter and stores that parameter.

has a public int getWait(int current) method that will return the difference between current and the clock time that was stored from the constructor.

the Teller class

contains a queue of Customer objects

has a constructor with 3 int parameters

the number of seconds to run the simulation

the maximum time before a new customer comes, in seconds

the maximum time to handle one customer's transactions, in seconds

has a public void run()method to run the simulation

Generate a random number less than the second constructor parameter for when the next customer arrives.

Loop while the clock variable is less than the number of seconds to run the simulation.

If the time has elapsed for a new customer to arrive, enqueue a new customer and generate a random number for the next clock time when a customer will arrive.

If the teller is not busy, dequeue a customer, accumulate the number of customers served and the total wait time, and generate a random number to calculate the next clock time when the teller will be free.

increment the clock

has a public void report()method to output, clearly labeled,

the Total time in minutes.

the Average wait time in minutes.

the Number served

If the queue is not empty:

the number of customers still in line

the wait time of the customer in front of the line, in minutes.

The main method should request a total number of seconds, a maximum number of seconds between customers and a maximum processing time in seconds, run the simulation, and print out a report. Try input like 7200, 360 and 240, where the teller can keep up, and like 7200, 240 and 360, where the teller can't keep up.

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

Students also viewed these Databases questions

Question

What is Accounting?

Answered: 1 week ago

Question

Define organisation chart

Answered: 1 week ago

Question

What are the advantages of planning ?

Answered: 1 week ago