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

You are to write a program name bank.java that simulates a bank. The program wil

ID: 3761961 • Letter: Y

Question

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.

Explanation / Answer

import javax.swing.*;

public class Banksim {

     private CustomerQueue CustomerQueue =

      new CustomerQueue("Customer");

    //private int maxProcessingTime;

   // private int totalTime;

    //private boolean showAll;

    //private int timeDone;

// Data Fields

/** Maximum time to service a Customer. */

private int maxProcessingTime;

/** Total simulated time. */

private int totalTime;

/** If set true, print additional output. */

private boolean showAll;

/** Simulated clock. */

private int clock = 0;

/** Time that the agent will be done with the current Customer.*/

private int timeDone;

private void runSimulation() {

    for (clock = 0; clock < totalTime; clock++) {

      CustomerQueue.checkNewArrival(clock, showAll);

      //regularCustomerQueue.checkNewArrival(clock, showAll);

      if (clock >= timeDone) {

        startServe();

      }

    }

}

private void enterData(){

     System.out.println(maxProcessingTime);

     System.out.println(CustomerQueue);

}     

private void startServe() {

      System.out.println("Time is " + clock

                         + " server is idle");

    }

}

/** Method to show the statistics. */

private void showStats() {

    System.out.println("The number of Customers served was "

                       + CustomerQueue.getNumServed());

    averageWaitingTime =

        (double) CustomerQueue.getTotalWait()

        / (double) CustomerQueue.getNumServed();

    System.out.println(" with an average waiting time of "

                       + averageWaitingTime);

    System.out.println("Customers in queue: "

                       + CustomerQueue.size());

   

}

/** main method

        @param args Not used

*/

public static void main(String args[]) {

        Banksim sim = new Banksim();

        sim.enterData();

        Customer.setMaxProcessingTime(sim.maxProcessingTime);

        sim.runSimulation();

        sim.showStats();

        System.exit(0);

}

}

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