Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Key Points Code must be object oriented Code must be thoroughly commented The project shall use the queue data structure learned in the course. Do not use the queue library. Scenario A supermarket has...

1 answer below »

Key Points

Code must be object oriented
Code must be thoroughly commented
The project shall use the queue data structure learned in the course. Do not use the queue library.

Scenario

A supermarket has 9 cashiers. A customer arrives every 3 seconds and a customer leaves every 6 seconds. The goal of the program is to put the next arriving customer in the shortest queue out of the 9 cashier queues. Your program will need to loop infinitely to simulate the passing of a certain amount of time. I suggest looping the program every second and clearing the screen and displaying all queues. Use asterisks (*) to represent customers in the queues and a for loop to create a one second delay.

Submit your final as a single word document with the code and output screenshots.

Good luck!

Answered Same Day Dec 12, 2021

Solution

Anandkumar answered on Dec 13 2021
119 Votes
Code:
required header files
#include #include using namespace std;
required class
class Cashier {
private:
required private variables
int first, last, size, count;
int *storage;
public:
create a constructo
Cashier(int n) {
initialize the variables
first = 0;
last = -1;
count = 0;
size = n;
dynamic storage
storage = new int[size];
}
checking for queue, if full
ool is_full() {
return count
eturn (count >= size);
}
check if queue is empty.
ool is_empty() {
eturn (count == 0);
}
adding the elements in queue
int enqueue(int el) {
check if it is not full
if (!is_full()) {
find the last
last = (last + 1) % size;
increment the counte
count++;
storage[last] = el;
return whn element is added
eturn 1;
} else {
return 0 when not added
eturn 0;
}
}
dequeue the elements
int dequeue() {
if (!is_empty()) {
int tmp = storage[first];
find the first
first = (first + 1) % size;
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here