0

(can someone solve the error pleasee) Write a simulation program of the lines at a grocery store. The program will have

#include<stdio.h> #include<stdlib.h> #include<time.h> struct queueNode { int customer_number; int serv_time; int arr_time; struct queueNode*nextPtr; }; typedef struct queueNode customer; typedef customer *customerPtr; void printQueue(customerPtr); int isEmpty(customerPtr); void dequeue(customerPtr*,customerPtr*); void enqueue(customerPtr*,customerPtr*,int,int,int); int main() { int i; int t_time = 0; int t_arrival = 0; int t_depart = -1; int customer_n = 0; int serv_timeime=0; int MAX_serv_timeIME = serv_timeime; int tot_wait_t=0; customerPtr headptr = NULL,tailptr = NULL; srand((unsigned int)time(NULL)); while(t_time !=0) { printf("TIME =%d,MAX_serv_timeIME =%d,TOT WAIT TIME=%d\n",t_time,MAX_serv_timeIME,tot_wait_t); if(t_time==t_depart && !isEmpty(headptr)) { printf("customer %d ON",headptr->customer_number); serv_timeime = headptr->serv_time; /*service time*/ tot_wait_t+=(t_time - headptr->arr_time); dequeue (&headptr,&tailptr); if(!isEmpty(headptr,tailptr); if(!isEmpty(headptr)) t_depart = serv_timeime + t_time; } if(t_time = =t_arrival) { serv_timeime = rand()%4 +1; MAX_serv_timeIME =(serv_timeime>MAX_serv_timeIME serv_timeime:MAX_serv_timeIME); if(isEmpty(headptr))t_depart = t_time + serv_timeime; enqueue(&headptr,&tailptr,customer_n,serv_timeime,t_arrival); t_arrival+=rand()%4+1; printf("customer %d joins at %d,serv_timeime %d,new_cust %d\n,",tailptr->customer_number,tailptr->arr_time,tailptr->serv_time,t_arrival); } printQueue(headptr); getchar(); t_time++; } customer_n =(tailptr->customer_number - headptr->customer_number)+1; printf("average wait time = %d,max service time= %d ,tot custs unserved %d",tot_wait_t/customer_n,MAX_serv_timeIME,customer_n); for(i=o;i<customer_n;i++) { printQueue(headptr); getchar(); dequeue(&headptr,&tailptr);}//printQueue(headptr); return 0; } void enqueue(customerPtr*headPtr,customerPtr *tailPtr,int customer_number,int serv_time,int arr_time) { customerPtr newPtr;newP

3rd Jun 2021, 1:52 AM
Muhammad Aiman Syafiq
Muhammad Aiman Syafiq - avatar
5 Respuestas
0
Write a simulation program of the lines at a grocery store. The program will have multiple queues instead of one. You might use a vector of queues to simulate the lines. Assumes that there are five cashier lines at the grocery store. Customer enter randomly to check out, and then enter the shortest line. If the line are equal, then the first available line is chosen. Each transaction takes a random amount of time to complete. For additional work, expand the grocery line program to allow shoppers to: • Avoid a line if all lines are a certain length • Leave a line if they have waited beyond a certain time • Check if another line is shorter at specified time intervals • Switch line if another line is shorter
3rd Jun 2021, 1:58 AM
Muhammad Aiman Syafiq
Muhammad Aiman Syafiq - avatar