{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Bank8Simulation

# Bank8Simulation - Bank8Simulation.java Author Lewis/Loftus...

This preview shows pages 1–2. Sign up to view the full content.

//******************************************************************* // Bank8Simulation.java Author: Lewis/Loftus // // Solution to Programming Project 12.6 // // Simulates customers waiting in eight lines at a bank using a queue // date structure. //******************************************************************* import java.util.Random; import java.text.DecimalFormat; public class Bank8Simulation { private Random gen; private int custCount; private Line[] lines; private int tellers[]; private int stats[]; private final int MAX_NUM_CUSTOMERS = 20; private final int MAX_CUST_SERVICED = 5; private final int NUM_TELLERS = 8; public Bank8Simulation() { gen = new Random(); custCount = 0; lines = new Line[NUM_TELLERS]; stats = new int[NUM_TELLERS]; for (int i = 0; i<NUM_TELLERS; i++) { lines[i] = new Line(); stats[i] = 0; } tellers = new int[NUM_TELLERS]; } //---------------------------------------------------------------- // Displays the stats for each teller, and identifies the teller // with the shortest waiting time on average. //---------------------------------------------------------------- private void displayStats(int numCycles) { float max = 0f; float average; int best = 0; DecimalFormat form = new DecimalFormat("#0.0"); System.out.println("\nAverage customers served per cycle:\n Teller number"); for (int i=0; i<NUM_TELLERS; i++) System.out.print(" " + i + " "); System.out.println("\n-----------------------------------------"); for (int i=0; i<NUM_TELLERS; i++) { System.out.print(" ");

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}