Description of Program You are to write a program name bank.java that simulates
ID: 3761618 • Letter: D
Question
Description of Program
You are to write a program name bank.java that simulates a bank. The program will prompt the user asking if they want to run the program again. If yes, then start the program over. If no, then terminate the program.
The execution phase run for 2 minutes during which time customers will arrive randomly between 2 - 6 seconds and be placed into a queue. Each customer will have a property relating to the amount of time he/she wants to spend with a teller, which is to be randomly generated to be between 2 and 5 seconds.
There would be a maximum of 5 tellers to attend to the customers. When you start the simulation, each teller is occupied.You will need to generate a random time for each of the first 5 customers occupying the tellers at the begining of the 2 minutes simulation.
As they finish attending a customer (based upon the amount of time associated with each customer), that teller becomes available for the next customer in the queue. As a customer is removed from the queue and sent to an "available" teller, then their availability is set to "False". Customers are allocated to any one of the 5 tellers that becomes available, and so on... until the time of 2 minutes for the simulation is finished.
If after 2 minutes, there are still customers in the queue, we would discard them, but still count them in the total count of customers that visited the bank. Also add into the total count of customer the first five customers that the tellers started out with as well as to the individual teller's total.
Finally display on the screen (at the end of each execution):
The total amount of customers that visited the bank for that 2 minutes.
The total amount of customers that each teller helped.
The total amount of time that each teller was occupied.
The total amount of customers that did not get to see a teller.
Explanation / Answer
package bank;
import java.util.Scanner;
import java.util.Random;
// simulate a bank Q
public class Bank {
static void funcCustQ(){
int [] cQ = new int[100]; // 100 customers can arrive in our Q cQ = Customer Queue
int t1,t2,t3,t4,t5; // teller1, teller2, ..., teller5;
// 1 = occupied, 0 = available
} // end customer Q function
static void simulate1() {
// start simulation for 2 minutes
int cust, tm, t=1; // time 720 ticks = 2 minutes
Random r = new Random();
for (tm = 1; tm <= 720; tm++)
t = r.nextInt(6); // max 5 tellers - becoming available randomly
cust = tm%60;
System.out.println(" Customer " + cust + " served by Teller " + t);
} // end function simulate1
public static void main(String[] args) {
int c = 1;
Scanner sc = new Scanner(System.in);
while (c == 1) {
System.out.println("Would you like to continue? 1 = Yes, 0 = No ");
c = sc.nextInt();
} // end while
} // end main
} // end class Bank