Question: I already have the coding in C programming. But I think, function to calculate average waiting time doesn't working. And this coding doesn't work to

I already have the coding in C programming. But I think, function to calculate average waiting time doesn't working. And this coding doesn't work to give the Platinum customer priority. I hope you can give me new coding or fix this coding thank you.
#include
struct Queue // circular queue struct { int size; int front; int rear; int *time_arr; };
int isEmpty(struct Queue *q) // function to check is queue is empty { if (q->rear == q->front) { return 1; } return 0; }
void enqueue(struct Queue *q, int time) // funntion to enqueue elements into the queue {
q->rear = (q->rear + 1) % q->size; q->time_arr[q->rear] = time; }
int dequeue(struct Queue *q) // funciton to dequeue elements from queue { int a = -1;
q->front = (q->front + 1) % q->size; a = q->time_arr[q->front]; }
int main() { // creating queue instances for gold and platinum customers struct Queue gold_customer; struct Queue platinum_customer;
// fixing size of queue as 10 , although user can change as per requirement gold_customer.size = 10; platinum_customer.size = 10;
// setting front and rear position of queue gold_customer.front = gold_customer.rear = 0; platinum_customer.rear = 0; platinum_customer.front = 0;
// dynamically allocating the queue array space gold_customer.time_arr = (int *)malloc(gold_customer.size * sizeof(int)); platinum_customer.time_arr = (int *)malloc(platinum_customer.size * sizeof(int));
printf("Enter total number of customers : "); int n; scanf("%d", &n); for (int i = 0; i
int random;
if (x == 1)
{
random = rand() % 30; enqueue(&gold_customer, random); printf("Your expected waiting time is %dS. Thankyou for your patience. ", random); }
if (x == 2)
{ random = rand() % 30; enqueue(&platinum_customer, random); printf("Your expected waiting time is %dS. Thankyou for your patience. ", random); } } printf(" "); while (isEmpty(&platinum_customer) == 0)
{
printf("Platinum customer with time expected %ds is served. ", dequeue(&platinum_customer)); }
while (isEmpty(&gold_customer) == 0)
{ printf("Gold customer with time expected %ds is served. ", dequeue(&gold_customer)); }
return 0; }
Task 1: Application of scheduling process in a phone answering system. System Details: - Tell Tone Sdn. Bhd. is a telecommunication company that has a phone answering system for its customer service centre. Whenever customers call the customer service center, they will be put in a queue before they are being served by the customer service representative. If the operators are busy, the customers are asked to wait and given a certain number. The time that a customer has to wait could be as short as a minute or as long as 30 minutes. This also depends on the types of customer. Platinum customer will be given a higher priority compared to a Gold customer. Thus, when a call from a Platinum customer came, it will be processed first. If there are no Platinum customer left in the queue, the system will serve the Gold customer. Demonstrate the scheduling process of a switch in a phone answering system by using queue. Construct a program to demonstrate the problem. Calculate the average waiting time for each call
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
