Question: 2 0 . 7 CIST 2 3 6 2 Lab: Simulating Cashiers This lab contains a main ( ) and several supporting classes: one for
CIST Lab: Simulating Cashiers
This lab contains a main and several supporting classes: one for Cashiers and one for Customers. Your goal is to implement main by filling in the missing code.
There are input parameters to the program:
Number of Cashiers: The number of cashiers on duty to serve customers.
Busy: This captures how busy the store will be during the simulation very light to extremely busy
Number of Minutes: This is the total number of time increments that simulation will run. Each iteration is minute.
The program uses the Busy parameter to determine how often a new customer comes into the location. The simulation will give each customer a service time, which is how long they need to be waited on by a cashier. Then the customer is added to the checkout line, where they wait for a cashier. Finally, when a customer is paired with a cashier, their service time determines how many iterations they spend with the cashier before leaving the store.
You will complete the main to make the above happen. Keep in mind that some of the functionality is already implemented in the classes: Customer and Cashier. Therefore, you need to spend time understanding what capabilities already exist.
In addition, the simulation outputs status logs throughout that will look as follows. This example assumes there is only cashier:
Time :
Customer Arrives Customer: arrived at: Remaining service time:
Customer serviced Customer: arrived at: Remaining service time: by cashier #
Length of Line:
Cashier Status
Cashier # Servicing: Customer
Time :
Customer Arrives Customer: arrived at: Remaining service time:
Length of Line:
Cashier Status
Cashier # Servicing: Customer
The sample output above shows that the first customer, Customer arrives at Time They have been assigned a service time of time units or iterations. Since the cashier is not busy they are immediately paired with the cashier # The line for cashiers is empty, and because of the pairing, the cashier # is serving Customer Then the program moves to Time Customer arrives at this time with a service time of This means Customer has twice as much service time requirements than Customer And because Customer is still being served by the one cashier, Customer is placed in line to wait.
Tasks
Complete the code in main.cpp You are free to add any helper functions to main.cpp as needed. Do not change any of the code in the Customer or Cashier classes.
HERE IS THE CODE TO BE MODIFIED
MAIN.CPP
#include "Customer.h
#include "Cashier.h
#include
#include
#include
#include
#include
int main
int numberOfcashiers ;
int busy ;
int numberOfMinutes ;
double totalWait ;
int numberOfCustomers ;
srand;
std::cin numberOfcashiers;
std::cin busy;
std::cin numberOfMinutes;
if numberOfcashiers
std::cout "number of cashiers must be greater than std::endl;
exit;
if busy busy
std::cout "busy should be between std::endl;
exit;
if numberOfMinutes
std::cout "number of minutes must be at greater than std::endl;
exit;
std::vector cashiernumberOfcashiers;
std::queue line;
maintain simulation time
for int time ; time numberOfMinutes; time
std::cout "Time time : std::endl;
a new customer may arrive of the time each minute
if rand busy
TODO: create a customer and put them into the line for service
check the status of each cashier. If one is available and
someone is waiting then they should be helped.
for int i ; i numberOfcashiers; i
TODO: write code that
performs service for customer that is currently being served by a cashier
assign customer to a free cashier
TODO: write code that output line length and cashier status
output stats related to average waiting time
std::cout std::fixed std::setprecision;
std::cout
;
std::cout "average wait: totalWait numberOfCustomers minutes." std::endl;
return ;
THE FOLLOWING CODE CANNOT BE MODIFIED:
CASHIER.CPP
#include "Cashier.h
#include
bool Cashier::isFree see if cashier is free to work
return free;
void Cashier::performService
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
