Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

nstructions Write a program that simulates customers waiting in line at a grocer

ID: 3565202 • Letter: N

Question

nstructions

Write a program that simulates customers waiting in line at a grocery store. Your program must use a Queue to represent the customer objects waiting in line.

A Customer class is provided for you. You must use that class, without alternations, for the creation of your Customer objects. You must analyze the class and use the provided methods to achieve the desired functionality of the program. You will also need to create two additional classes. The first will be a Linked List Queue that will represent the data structure for holding your Customer objects. The second is a driver where your store simulation will take place.

The program (driver) should simulate 60 minutes of activity at the store. Each iteration of your program should represent one minute. At each iteration (minute), your program should do the following:

Check to see if new customers are added to the queue. There is a 25% chance that new customers show up (need to be added to the queue) every minute. This does not mean you should add a customer every four iterations, but rather each iteration should have its own 25% chance.

Update the customer object currently being serviced (if one exists). This will be the customer object at the front of the queue. If the customer has been completely serviced, remove them from the queue.

During execution, your program should output the following information:

When a new customer is added to the queue, output,

Explanation / Answer

import java.util.*; import java.util.Random; public class GroceryStore{ public static void main (String[] args){ int newCust=0; //to hold random variable 1-4 for 25% chance of new customer Queue myQueue = new LinkedList(); //instantiates new queue int wait = 0; int numCust = 0; //holds counter for number of customer for (int i = 1; i