Question: 1) Ask a user to input for length of processing time, number of queues, number of customers, and customer arrival rate for the simulation. Then,

1) Ask a user to input for length of processing time, number of queues, number of customers, and customer arrival rate for the simulation. Then, use this in your queue simulation. (ask user input and able to use & run simulation based on the input -- 40 points) ===>>> The example in the chapter has these values as 120, 10, 100, and 15, respectively. (2) Ask a user to input a preferred average time, in minutes. (10 points) ===>>> The example in the chapter has this value as 7 minutes (3) Based on the simulation result, you will tell the user how many cashiers that they need to meet (or within) the average time user enter. (use simulation results and answer this question -- 15 points) ===>>> The example in the chapter has the result of 6 cashiers. (4) Ask the user if they want to run another simulation. If so, repeat (1 - 3).

stuck on part 3 and 4

import java.util.*; public class Outcome { public static void main(String[] args) { Scanner keyboard=new Scanner(System.in); System.out.println("What would you like the process time to be?"); int PROCESS = keyboard.nextInt(); System.out.println("How many cashies do you want to have?"); int MAX_CASHIERS = keyboard.nextInt(); System.out.println("How many customers would you like?"); int NUM_CUSTOMERS = keyboard.nextInt(); System.out.println("How far apart would you like the customers to come"); int x=keyboard.nextInt(); Customer customer; Queue customerQueue = new LinkedList(); int[] cashierTime = new int[MAX_CASHIERS]; int totalTime, averageTime, departs, start; // run the simulation for various number of cashiers for (int cashiers = 0; cashiers < MAX_CASHIERS; cashiers++) { // set each cashiers time to zero initially for (int count = 0; count < cashiers; count++) cashierTime[count] = 0; // load customer queue for (int count = 1; count <= NUM_CUSTOMERS; count++) customerQueue.add(new Customer(count * x)); totalTime = 0; // process all customers in the queue while (!(customerQueue.isEmpty())) { for (int count = 0; count <= cashiers; count++) { if (!(customerQueue.isEmpty())) { customer = customerQueue.remove(); if (customer.getArrivalTime() > cashierTime[count]) start = customer.getArrivalTime(); else start = cashierTime[count]; departs = start + PROCESS; customer.setDepartureTime(departs); cashierTime[count] = departs; totalTime += customer.totalTime(); } } } // output results for this simulation averageTime = totalTime / NUM_CUSTOMERS; System.out.println("Number of cashiers: " + (cashiers + 1)); System.out.println("Average time: " + averageTime + " "); } System.out.println("What is your preferred average time in minutes"); int input=keyboard.nextInt()*60; System.out.println("In order to keep your average time at or below "+input/60); } }

public class Customer { private int arrivalTime, departureTime; /** * Creates a new customer with the specified arrival time. * @param arrives the arrival time */ public Customer(int arrives) { arrivalTime = arrives; departureTime = 0; } /** * Returns the arrival time of this customer. * @return the arrival time */ public int getArrivalTime() { return arrivalTime; } /** * Sets the departure time for this customer. * @param departs the departure time **/ public void setDepartureTime(int departs) { departureTime = departs; } /** * Returns the departure time of this customer. * @return the departure time */ public int getDepartureTime() { return departureTime; } /** * Computes and returns the total time spent by this customer. * @return the total customer time */ public int totalTime() { return departureTime - arrivalTime; } }

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!