Question: 2 0 . 7 CIST 2 3 6 2 Lab: Simulating Cashiers This lab contains a main ( ) and several supporting classes: one for

20.7 CIST2362 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 3 input parameters to the program:
1. Number of Cashiers: The number of cashiers on duty to serve customers.
2. Busy: This captures how busy the store will be during the simulation 0(very light) to 10(extremely busy).
3. Number of Minutes: This is the total number of time increments that simulation will run. Each iteration is 1 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 1 cashier:
Time 0:
++Customer 0 Arrives { Customer: 0 arrived at: 0, Remaining service time: 2}
**Customer 0 serviced { Customer: 0 arrived at: 0, Remaining service time: 2} by cashier #0
Length of Line: 0
Cashier Status
========================================
Cashier #0 Servicing: Customer 0
Time 1:
++Customer 1 Arrives { Customer: 1 arrived at: 1, Remaining service time: 4}
Length of Line: 1
Cashier Status
========================================
Cashier #0 Servicing: Customer 0
The sample output above shows that the first customer, Customer 0, arrives at Time 0. They have been assigned a service time of 2 time units or iterations. Since the cashier is not busy they are immediately paired with the cashier #0. The line for cashiers is empty, and because of the pairing, the cashier #0 is serving Customer 0. Then the program moves to Time 1. Customer 1 arrives at this time with a service time of 4. This means Customer 1 has twice as much service time requirements than Customer 0. And because Customer 0 is still being served by the one cashier, Customer 1 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 =5;
int busy =10;
int numberOfMinutes =180;
double totalWait =0;
int numberOfCustomers =0;
srand(25);
std::cin >> numberOfcashiers;
std::cin >> busy;
std::cin >> numberOfMinutes;
if (numberOfcashiers <1){
std::cout << "number of cashiers must be greater than 0"<< std::endl;
exit(1);
}
if (busy <0|| busy >10){
std::cout << "busy should be between 0-10"<< std::endl;
exit(1);
}
if (numberOfMinutes <1){
std::cout << "number of minutes must be at greater than 0"<< std::endl;
exit(1);
}
std::vector cashier(numberOfcashiers);
std::queue > line;
// maintain simulation time
for (int time =0; time < numberOfMinutes; time++){
std::cout << "Time "<< time <<":"<< std::endl;
// a new customer may arrive 10% of the time each minute
if ((rand()%10)< 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 =0; 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(2);
std::cout <<"
";
std::cout << "average wait: "<<(totalWait / numberOfCustomers)<<" minutes." << std::endl;
return 0;
}
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!