Modify the AWT model to: a) report out the largest number of customers enqueued
ID: 3817779 • Letter: M
Question
Modify the AWT model to:
a) report out the largest number of customers enqueued at the same time
b) assign the next arriving customer to a specific queue based on shortest finish time
c) provide a user interface control to allow user to select shortest finish time or shortest queue for assignments
create the program that is capable of answering these questions. with user inputed data such as arrival time, service time, number of customers, and ranges. then asks if the user wants to do it again with y/n:
determine a reasonable number of queues to use if there are 1000 customers and:
a) The inter-arrival time is 5 and the service time is 5
b) The inter-arrival time is 1 and the service time is 5
c) The inter-arrival time ranges from 0 to 20, and the service time ranges from 20 to 100
d) The inter-arrival time ranges from 0 to 2, and the service time ranges from 20 to 100
use these:
Customer Generator
//----------------------------------------------------------------------
// CustomerGenerator.java by Dale/Joyce/Weems Chapter 5
//
// Generates a sequence of random Customer objects based on the
// constructor arguments for min and max interarrival and service times.
// Assumes a flat distribution of both interarrival and service times.
// Assumes time starts at 0.
//----------------------------------------------------------------------
package support;
import java.util.Random;
public class CustomerGenerator
{
protected int minIAT; // minimum inter-arrival time
protected int maxIAT; // maximum inter-arrival time
protected int minST; // minimum service time
protected int maxST; // maximum service time
protected int currTime = 0; // current time
Random rand = new Random(); // to generate random numbers
public CustomerGenerator (int minIAT, int maxIAT, int minST, int maxST)
// Preconditions: all arguments >= 0
// minIAT <= maxIAT
// minST <= maxST
{
this.minIAT = minIAT;
this.maxIAT = maxIAT;
this.minST = minST;
this.maxST = maxST;
}
public void reset()
{
currTime = 0;
}
public Customer nextCustomer()
// Creates and returns the next random customer.
{
int IAT; // next inter-arrival time
int ST; // next service time
IAT = minIAT + rand.nextInt(maxIAT - minIAT + 1);
ST = minST + rand.nextInt(maxST - minST + 1);
currTime = currTime + IAT; // updates current time to the arrival
// time of next customer
Customer next = new Customer(currTime, ST);
return next;
}
}
customer
//----------------------------------------------------------------------
// Customer.java by Dale/Joyce/Weems Chapter 5
//
// Supports customer objects having arrival, service, and finish time
// attributes. Responsible for computing and returning wait time.
//----------------------------------------------------------------------
package support;
public class Customer
{
protected int arrivalTime;
protected int serviceTime;
protected int finishTime;
public Customer(int arrivalTime, int serviceTime)
{
this.arrivalTime = arrivalTime;
this.serviceTime = serviceTime;
}
public int getArrivalTime()
{
return arrivalTime;
}
public int getServiceTime()
{
return serviceTime;
}
public void setFinishTime(int time)
{
finishTime = time;
}
public int getFinishTime()
{
return finishTime;
}
public int getWaitTime()
{
return (finishTime - arrivalTime - serviceTime);
}
}
Explanation / Answer
package support;
import java.util.Random;
public class CustomerGenerator
{
protected int minIAT; // minimum inter-arrival time
protected int maxIAT; // maximum inter-arrival time
protected int minST; // minimum service time
protected int maxST; // maximum service time
protected int currTime = 0; // current time
Random rand = new Random(); // to generate random numbers
public CustomerGenerator (int minIAT, int maxIAT, int minST, int maxST)
// Preconditions: all arguments >= 0
// minIAT <= maxIAT
// minST <= maxST
{
this.minIAT = minIAT;
this.maxIAT = maxIAT;
this.minST = minST;
this.maxST = maxST;
}
public Customer nextCustomer()
// Creates and returns the next random customer.
{
int IAT; // next inter-arrival time
int ST; // next service time
IAT = minIAT + rand.nextInt(maxIAT - minIAT + 1);
ST = minST + rand.nextInt(maxST - minST + 1);
currTime = currTime + IAT; // updates current time to the arrival
// time of next customer
Customer next = new Customer(currTime, ST);
return next;
}
}
customer
//----------------------------------------------------------------------
// Customer.java by Dale/Joyce/Weems Chapter 5
//
// Supports customer objects having arrival, service, and finish time
// attributes. Responsible for computing and returning wait time.
//----------------------------------------------------------------------
package support;
public class Customer
{
protected int arrivalTime;
protected int serviceTime;
protected int finishTime;
public Customer(int arrivalTime, int serviceTime)
{
this.arrivalTime = arrivalTime;
this.serviceTime = serviceTime;
}
public int getArrivalTime()
{
return arrivalTime;
}
public int getFinishTime()
{
return finishTime;
}
public int getWaitTime()
{
return (finishTime - arrivalTime - serviceTime);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.