can someone check my simulation?

Hello, i have an assignment where i need to make a simulation of a checkout line of a supermarket. for example, when the first customer arrives, say so and start servicing the customer. when the 2nd customer arrives, if the 1st is done, begin servicing the 2nd. else, queue the 2nd customer. so far i have made a program that does that but im not sure if its right. can anyone check it? thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 #include <iostream>
#include <queue>
#include <stdlib.h>
#include <time.h>
using namespace std;


main(){
int ctr = 1, arrival, service;
queue<int>waiting;
queue<int>customerNo;

srand(time(NULL));

arrival = rand() % 4 + 1;

for(int i = 0; i < 14; ){
    cout<<"\nCustomer #"<<ctr<<" arrived in "<<arrival<<" minute(s).";
    i = i + arrival;
    ctr++;
    service = rand() % 4 + 1;
    cout<<"\nTime served customer #"<<ctr-1<<": "<<service;
    arrival = rand() % 4 + 1;

    while(service > arrival){
        cout<<"\nCustomer #"<<ctr<<" arrived in "<<arrival<<" minute(s)";
        cout<<"\nCustomer #"<<ctr<<" is enqueued.";
        customerNo.push(ctr);
        ctr++;
        customerNo.push(ctr);
        service = service - arrival;
        arrival = rand() % 4 + 1;
        while(service < arrival){
            cout<<"\nNow serving customer #"<<customerNo.front();
            service = rand() % 4 + 1;
            arrival = rand() % 4 + 1;
            cout<<"\nTime served customer #"<<customerNo.front()<<": "<<service;
            customerNo.pop();
        }
    }

}

}
Topic archived. No new replies allowed.