Question: Write a simulation program to simulate lines at a grocery store for a typical days business. You will assume there are three cashier lines at
Write a simulation program to simulate lines at a grocery store for a typical days business. You will assume there are three cashier lines at the grocery store. Customers will enter randomly to check out (this is a time stamp in the input file) and will enter the shortest line. If the lines are equal, then the first line in the queue will be selected. Each transaction takes a random amount of time to complete (this also is a number from the input file). The grocery store operates on a ten hour business day and only 6 customers per queue will be able to wait for service at any time. If a customer arrives and there are 6 in all the queues, the customer will be turned away. To perform the simulation, a number, a time stamp, and a service time (randomly generated between 1 and 20 minutes) is given for each customer. This information will be in an input file. The first item in the input file will be the number of customers in the file. To keep the simulation simple, this time stamp will be a count of the number of minutes elapsed from the start of the business day. The time stamps will be in order in the file. So the time could be any values from 0 to 570 (no new business will be allowed 30 minutes before closing, so the waiting queue can be cleared out, hopefully, before the end of the business day.) There will be a time counter which will start at 0 when the simulation starts. No two customers can arrive at the same minute. Customers should be taken out of the queue when the cashier starts serving them. This simulation will inform the owner how many customers were serviced, how many were turned away, the average time any customer in the queue spent waiting, and the total time customers spent waiting. You will generate your own input file to test your program that will have a number, a time stamp from 0 to 570 in order, and a service time. Those will be your customers. The grader will use a standard file to test all the projects. To simulate the time, you will use a loop that increments the timer by 1 each time through the loop. The Results are written on an output file. The following classes are examples of classes you might need: class Node { }; class Queue { }; class Customer { int number; // Assign int arrival_time; int serv_time; }; class Cashier { int timer; // minutes in use char status; // a - available, i inactive int time_limit; // depends on customer serv_time ... }; class Sim_data_type { int time_cnt; // ranges in values from 0 to 570 int num_serviced; // number of customers serviced so far long tot_wait_time; // of all customers in the queues Iit num_turned_away; // count of customers turned away }; Sample data: 1 10 1 2 17 3 3 20 7 4 22 2 5 25 5 . . . 30 73 2 Sample output data: Total number of customers serviced: 35 Total number of customers turned away: 1 Average wait time: 6 Total wait time: 12
Some definitions:
Wait time is the time the customer enters the queue and does not include the service time.
Arrival time is the time the customer can go into the queue.
Service time is how long it takes for a cashier to service a customer. During that time, no other customers can be serviced by that cashier.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
