Question

Problem : Simulate a call center queue system Simulate a call center queue system. When a...

Problem : Simulate a call center queue system

Simulate a call center queue system. When a customer calls to the call center, it will take the

account number and name as input and put the customer in a queue. Consider a queue of

customer type with maximum size of 6. Use circular queue for your solution. The customer

structure is described below:

Typedef struct Customer

{

int account_no;

char name[100];

} customer;

In an infinite loop, randomly choose between option ‘c’ (call) or ‘s’ (serve). Maybe put ‘c’ and

‘s’ in a character array and use rand() method to choose between array index.

-

If ‘c’ is picked, we assume a call is made. If the queue is full, inform the user that the system

reached maximum capacity and to call later. If the queue is not full, ask the user to enter the

account_no and name. Then put the user into Queue and display the queue with all the user

account no and name based on their priority.

-

If ‘s’ is picked we assume the front customer will be served. Remove the customer from the

queue and display the queue based on their priority.

Press ctrl+c to close your program whenever you want to.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define SIZE 6

typedef struct Customer
{
int account_no;
char name[100];
}customer;
customer queue[SIZE];
int front = -1, rear =-1;
int isFull()
{
if( (front == rear + 1) || (front == 0 && rear == SIZE-1))
return 1;
return 0;
}

int isEmpty()
{
if(front == -1)
return 1;
return 0;
}

void enQueue()
{
if(isFull())
printf("\nSystem reached maximum capacity. Please call later\n");
else
{

//when queue is not full we take the customer details and push him to queue
int account_no;
char name[100];
if(front == -1)
front = 0;
rear = (rear + 1) % SIZE;
printf("Enter account number and name\n");
scanf("%d",&account_no);
scanf("%s",name);
queue[rear].account_no = account_no;
strcpy(queue[rear].name,name);
printf("You are now in queue\n");
display();
}
}


void deQueue()
{
if(isEmpty()) {
printf("\nNo customers in queue !! \n");
return(-1);
}
else
{

//when queue is not empty we serve him so dequeueing
if (front == rear)
{
front = -1;
rear = -1;
}
else
{
front = (front + 1) % SIZE;
  
}
printf("You are now moved out of queue\n");
display();
}
}

//function to display the state of the queue
void display()
{
int i;
if(isEmpty())
printf(" \nNo customers in queue !! \n");
else
{
printf(" \nQueue State\n");
for( i = front; i!=rear; i=(i+1)%SIZE)
{
printf("%d %s\n",queue[i].account_no,queue[i].name);
}
printf("%d %s\n",queue[i].account_no,queue[i].name);
}
}

int main()
{
while(1)
{

//randomly generating a choice between 0 and 1. 0 means c call, 1 means s serve
int n = rand() % 2;
if(n==0)
enQueue();
else
deQueue();
}
return 0;
}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
Problem : Simulate a call center queue system Simulate a call center queue system. When a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C++ Task 3: Use the stack and queue to simulate receiving and transforming data We are creating a system that will co...

    In C++ Task 3: Use the stack and queue to simulate receiving and transforming data We are creating a system that will convert strings sent over a serial bus one character at a time. The conversion will be from big to little endian or from little to big endian. To simplify this, each character will be considered a word. Little endian will have the lowest address first. Big endian will have the biggest address first. For example (for this lab),...

  • You are to simulate a dispatcher using a priority queue system. New processes are to be...

    You are to simulate a dispatcher using a priority queue system. New processes are to be entered using a GUI with priority included (numbering should be automatic). Processes are also to be terminated by GUI command. Context switches are to be by command with the cause of the switch being immaterial. Assume only one CPU. Priorities and numbers of processes can be kept small, just big enough to demonstrate the below listed functionality. You may pre-populate the queues initially from...

  • C programming Construct a console program to simulate Zoo ticketing system. The system is used for...

    C programming Construct a console program to simulate Zoo ticketing system. The system is used for dispensing tickets to customers. In order to buy tickets, the customer need to enter the following information: a) Number of ticket they want to buy. Everybody must have a ticket to enter. b) Only up to 5 tickets may be purchased for every transaction or customer. c) Type of ticket either for adult, children (aged 5 12 years old) or toddler (aged 2-5 years...

  • C++ -- Event processing simulation using a transaction queue Hi! it is queue simulation please read...

    C++ -- Event processing simulation using a transaction queue Hi! it is queue simulation please read the instructions, write codes, and explain the code with comments. Thank you Transactions enter the system and are stored in a queue. Each transaction represents some work that needs to be accomplished. Servers exist which process transactions. Servers take transactions off the queue and process them. you’re building the simulation framework. The idea is that somebody would take your framework, and add the specifics...

  • Build a bank simulator system using the C++ STL queue library. You are required to create your ow...

    build a bank simulator system using the C++ STL queue library. You are required to create your own ADT for that system that: First, Read from a file the data of incoming customers which includes ArrivalID, StartTime, and ProcessTime. You have one line in your Bank in which you will serve your customers as per to their arrival time. For example if you read the following data from the file A 1 5 B 2 5 C 4 5 D...

  • Build a bank simulator system using the C++ STL queue library. You are required to create your ow...

    build a bank simulator system using the C++ STL queue library. You are required to create your own ADT for that system that: First, Read from a file the data of incoming customers which includes ArrivalID, StartTime, and ProcessTime. You have one line in your Bank in which you will serve your customers as per to their arrival time. For example if you read the following data from the file A 1 5 B 2 5 C 4 5 D...

  • A priority queue is a collection of items each having a priority. A priority queue supports three...

    A priority queue is a collection of items each having a priority. A priority queue supports three fundamental operations. You can ask a priority queue whether it is empty. You can insert an item into the priority queue with a given priority. You can remove the item from the priority queue that has the smallest priority. For example, suppose that you start with an empty priority queue and imagine performing the following steps. Insert item "one" with priority 10. Insert...

  • Hi! it is c++ queue simulation please read the instructions, write codes, and explain the code...

    Hi! it is c++ queue simulation please read the instructions, write codes, and explain the code with comments. Thank you Transactions enter the system and are stored in a queue. Each transaction represents some work that needs to be accomplished. Servers exist which process transactions. Servers take transactions off the queue and process them. you’re building the simulation framework. The idea is that somebody would take your framework, and add the specifics for whatever type of system it was going...

  • Q1. Write a program to simulate a grocery waiting queue. Your program should ask the user...

    Q1. Write a program to simulate a grocery waiting queue. Your program should ask the user if they want to add a customer to the queue, serve the next customer in the queue, or exit. When a customer is served or added to the queue, the program should print out the name of that customer and the remaining customers in the queue. The store has two queues: one is for normal customers, another is for VIP customers. Normal customers can...

  • Question: C Programming Problem: Pointer and Struct Description: The purpose of this assignment is to prov......

    Question: C Programming Problem: Pointer and Struct Description: The purpose of this assignment is to prov... C Programming Problem: Pointer and Struct Description: The purpose of this assignment is to provide practice programming using structs and pointers. Your program will accept user input and store it in a dynamic array of structs. First, you will define a structure to describe a item to be bought. Your program will prompt the user for the initial size of the array. It will...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT