Hello, I am having some trouble with a supermarket checkout simulation program.
ID: 3776947 • Letter: H
Question
Hello, I am having some trouble with a supermarket checkout simulation program. What I have so far just basically adds customers to the queue and prints when they arrive. I am struggling with how to implement a way of keeping track of when a given customer finishes(I will attach what I have so far). I had already created queue and node classes (with headers and cpp files) that I modified in my attempt. I would be very grateful if you could give me some help with this assignment, my teacher was not very clear on how to do this and it is far beyond what we have done so far. I have found one solution but it uses friend functions (which we have not gone over yet and I cannot use) and does not work well. Here are the requirements for the project:
(Please do not use trees or friend functions as we have not gone over those in class, we're only supposed to use a node and queue class, which can instead be titled customer and lane)
Write a program that simulates a checkout line at a supermarket. Customers arrive in random intervals from 1 - 4 minutes. Each customer is also serviced from 1 - 4 minutes. The store starts the day with 3 lanes open. Run the simulation for a 12-hour day (720 minutes) using the following to help you.
1. Get a random integer between 1 and 4 (customer arrival time)
2. Determine that customer’s service time (another random integer!)
3. Begin servicing that customer (all lines are empty!)
4. Don’t forget to account for all of the following throughout the “day”! a. calculate when customers arrive b. When they do, output a message (include customer ID and time of arrival) c. Enqueue them into a lane (think of logic to prevent 1 lane always being chosen!) d. When a customer is done being serviced, output a message (include customer ID and total time they spend in the queue) e. Dequeue the customer when they are finished Answer the following questions after your simulation is complete.
1. What was the maximum number of customers in line (across all lines) at any time? How many were in each line?
2. What was the longest wait time for a customer?
3. Change the arrival time to 2-5 minutes, how does this affect the outcome? Re-answer problems 1 & 2 with these settings.
4. What are the minimum number of lanes that must be open to keep all customer’s waiting times < 5 minutes using both of the arrival time intervals? How about for < 10 minutes?
Explanation / Answer
Hey I thought of one idea, and I didnt get completely but I am able to understand something about it. First customer Id and other data is taken , as many customers as present the data is taken, later we have to run the loop for 720 at the interval 4 minutes ( because customer can enter 1-4 minutes and be serviced in 1-4) and dequeue each customer , you can use random numbers package and get random numbers in 1-4 for cutomer arrival time , when dequeing from customer queue output customer details with arrival time. Now the customer is chosen in any of the lanes and enqueued into that lane, we can implement this by chosing linearly i.e. one customer lane one and other lane two then you find another random number for each customer service, and store their waiting time now waiting time is random number i.e. service time.
Finally you store some results regarding maximum waiting time or maximum number of customers.
This is what I understood so far.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.