Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Based on these instructions: Customers at airlines and banks typically join a single queue. They move through the queue and eventually take their place at
Based on these instructions: Customers at airlines and banks typically join a single queue. They move through the queue and eventually take their place at one of the open counters or "service areas." Each customer then conducts hisher business and leaves. The situation is diagrammed here:
Suppose an airline or a bank wants to measure the waittimes to serve each customer, from the minute they enter to the minute they leave. The airline hires you to program a simulation of the situation.
You need one queue.
You need an array of the correct size to represent the service areas.
You need to know how often, the frequency per minute, that customers join the queue.
You need to know how long it takes a random number to conduct the customer's business after they arrive at the service area. We will count each minute down to after which the customer leaves.
You need to store the time at which the customer entered the queue.
You need to calculate how long the customer spent getting served the total wait time from the minute they entered to the minute they left.
You need to know how long to run the simulation.
For each minute write to a file:
Each minute, starting from
The service areas serving their customers. Each customer shows the time remaining until they complete their business and leave.
The queue with its customers, showing the time they need to complete their business.
The total customers served.
The average wait time per customer.
The longest wait time of any customer.
The length of the longest queue of customers.
Customers in a Queue Simulation!
How many service areas?
How long, in minutes, should the simulation run?
Total customers served
Average wait time
Longest wait time
Longest queue
You need to generate two random numbers in this lab:
whether a customer joins the queue during that minute. Let's set the frequency at an chance per minute.
how long it takes to conduct the customer's business after they get to the service area. Let's generate a random integer between and minutes, inclusive.
The Customer class
It seems like a Customer class would be a good way to model the situation.
Complete this code:
import java.util.;
import java.io;
public class SeniorsFirst
public static final int CUSTOMERSPERMINUTE ;
public static void mainString args
PrintWriter outfile setUpFile;
System.out.printlnSeniors First Simulation! ;
Scanner kb new ScannerSystemin;
System.out.printHow many cashiers? ;
int numberofcashiers kbnextInt;
System.out.printHow long, in minutes, should the simulation run? ;
int time kbnextInt;
waitTimestime numberofcashiers, outfile; run the simulation
public static PrintWriter setUpFile
PrintWriter outfile null;
try
outfile new PrintWriternew FileWritercustomerWaitTimestxt;
catchIOException e
System.out.printlnFile not created";
System.exit;
return outfile;
public static void outfileCashiersAndQueuesPrintWriter outfile, int min, ArrayList cashier
outfile.printlnminute min : ;
for Queue q : cashier
outfile.print;
ifqisEmpty outfile.printnull;
for Customer c : q
outfile.print ctoString;
outfile.println;
public static double calculateAverageint totalMinutes, int customers
return int totalMinutescustomers ;
public static void waitTimesint time, int numberofcashiers, PrintWriter outfile
int customers ;
int customersCheckedOut ;
String classes new StringSenior "Junior", "Sophomor", "Freshman";
int served new int;
int longestWait new int;
int totalWait new int;
ArrayList cashiers new ArrayList;
forint i; i;
Write your code for the simulation.
call outfileCashiersAndQueues to write the queues to the file.
report the results to the screen in table form, like this:
Customer Total Longest Average Wait
Senior
Junior
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started