Question: please solve this using the code given on the bottom. please show the output and the previous question has also been added for reference Code:

please solve this using the code given on the bottom. please show the output and the previous question has also been added for reference

please solve this using the code given on the bottom. please show

the output and the previous question has also been added for reference

Code: public class BankSimulation{ private final List queue; private int totalWaitingTime; BankSimulation()

Code:

public class BankSimulation{ private final List queue; private int totalWaitingTime; BankSimulation() { queue = new ArrayList(); totalWaitingTime = 0; } public void runSimulation() throws FileNotFoundException { final Scanner filereader = new Scanner(new File("input.txt")); int previousDepartureTime = 0; // until there is input while (filereader.hasNext()) { final Event arrivalEvent = new Event(filereader.nextInt(), "arrival"); final int processingTime = filereader.nextInt(); int departureTime = 0; if (arrivalEvent.getTime() > previousDepartureTime) {// immediate processing departureTime = arrivalEvent.getTime() + processingTime; } else { // wait to get processed departureTime = previousDepartureTime + processingTime; } previousDepartureTime = departureTime; totalWaitingTime = totalWaitingTime + departureTime - arrivalEvent.getTime() - processingTime; final Event departureEvent = new Event(departureTime, "departure"); queue.add(arrivalEvent); // add the arrival and departure events to queue. queue.add(departureEvent); } filereader.close(); Collections.sort(queue, new ListComparator()); } public void printResults() { System.out.println("---Simulation Begins---"); for (final Event event : queue) { if (event.getType().equals("arrival")) { System.out.println("Processing an arrival event at time: " + event.getTime()); }else { System.out.println("Processing a deparature event at time: " + event.getTime()); } } System.out.println("---End of Simulation---"); System.out.println("Final Statistics: "); System.out.println("Total number of people processed: " + queue.size() / 2); System.out.println("Average amount of time spent waiting: " + (float) totalWaitingTime / (queue.size() / 2)); } public static void main(String[] args) throws FileNotFoundException { final BankSimulation bankSimulation = new BankSimulation(); bankSimulation.runSimulation(); bankSimulation.printResults(); } }

The bank is considering the following change: Instead of having three distinct lines (one for each teller), there will be a single line for the three tellers. The person at the front of the line will go t the first available teller. Modify the simulation of Part c to account for this variation. Run both simulations on several sets of input data. How do the various statistics compare (averages and maximums)? What can you conclude about having a single line as opposed to having distinct lines? a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!