Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

finish up the code below so it runs as so: Customers in a Queue Simulation! How many service areas? 4 How long, in minutes, should

finish up the code below so it runs as so: Customers in a Queue Simulation!
How many service areas? 4
How long, in minutes, should the simulation run? 60
Total customers served =33
Average wait time =9.6
Longest wait time =16
Longest queue =11 this is the code so far: import java.util.*;
import java.io.*;
public class CustomersInQueue
{
public static final double CHANCE_OF_CUSTOMER =0.8; //
public static void outfileServiceAreasAndQueue(PrintWriter outfile, int min, Customer[] atServiceWindow, Queue queue)
{
outfile.print(min +": ");
for(Customer c : atServiceWindow)
if( c != null )
outfile.print(c.toString()+"");
outfile.println(""+ queue);
}
public static double calculateAverage(int totalMinutes, int customers)
{
return (int)(1.0* totalMinutes/customers *10)/10.0;
}
public static PrintWriter setUpFile()
{
PrintWriter outfile = null;
try
{
outfile = new PrintWriter(new FileWriter("customersSimulation.txt"));
}
catch(IOException e)
{
System.out.println("File not created");
System.exit(0);
}
return outfile;
}
public static void main(String[] args)
{
PrintWriter outfile = setUpFile();
System.out.println("Customers in a Queue Simulation! ");
Scanner kb = new Scanner(System.in);
System.out.print("How many service areas? ");
int sa = kb.nextInt();
System.out.print("How long, in minutes, should the simulation run? ");
int time = kb.nextInt();
serveTheCustomers(time, sa, outfile); //run the simulation
}
public static void serveTheCustomers(int time, int number_of_serviceAreas, PrintWriter outfile)
{
/***************************************
call outfileTimeAndQueue() to store the queue to the file.
**********************************/
}
static class Customer
{
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Power Of Numbers In Health Care A Students Journey In Data Analysis

Authors: Kaiden

1st Edition

8119747887, 978-8119747887

More Books

Students also viewed these Databases questions