Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Im working on a project that one of the output has to be like the one below: Booth 1 TANVIR from line 6 checks out

Im working on a project that one of the output has to be like the one below:
Booth 1
TANVIR from line 6 checks out at time 82.
ARUP from line 6 checks out at time 152.
TRAVIS from line 6 checks out at time 382.
GUSTAVO from line 6 checks out at time 687.
DANIEL from line 3 checks out at time 817.
ANEESHA from line 3 checks out at time 1197.
GUHA from line 6 checks out at time 1427.
SHARON from line 5 checks out at time 5055.
Booth 2
XIE from line 10 checks out at time 345.
JOSE from line 9 checks out at time 475.
VENU from line 8 checks out at time 625.
ANSH from line 8 checks out at time 685.
NELLY from line 9 checks out at time 765.
Booth 3
LILY from line 11 checks out at time 65.
MEADE from line 12 checks out at time 395.
MASON from line 12 checks out at time 485.
LEAVENS from line 11 checks out at time 9040.
but currently, my output is just:
Booth 1
Booth2
Booth3
The input is as follows:
173
TANVIR 102
ARUP 84
TRAVIS 405
LILY 510
XIE 6015
GUSTAVO 5516
JOSE 2023
DANIEL 2027
VENU 2428
ANEESHA 7029
ANSH 635
GUHA 4036
MEADE 6038
MASON 1240
NELLY 10150
SHARON 55000
LEAVENS 29000
Please help me solve the issues, my code is this:
#include
#include
#include
struct Customer {
char name[51];
int tickets;
int arrivalTime;
};
struct QueueNode {
struct Customer customer;
struct QueueNode* next;
};
struct Queue {
struct QueueNode* front;
struct QueueNode* rear;
};
void initializeQueue(struct Queue* queue){
queue->front = NULL;
queue->rear = NULL;
}
int isQueueEmpty(struct Queue* queue){
return (queue->front == NULL);
}
void enqueue(struct Queue* queue, struct Customer customer){
struct QueueNode* newNode =(struct QueueNode*)malloc(sizeof(struct QueueNode));
newNode->customer = customer;
newNode->next = NULL;
if (isQueueEmpty(queue)){
queue->front = newNode;
queue->rear = newNode;
} else {
queue->rear->next = newNode;
queue->rear = newNode;
}
}
struct Customer dequeue(struct Queue* queue){
if (isQueueEmpty(queue)){
struct Customer emptyCustomer;
strcpy(emptyCustomer.name, "");
emptyCustomer.tickets =0;
emptyCustomer.arrivalTime =0;
return emptyCustomer;
} else {
struct QueueNode* temp = queue->front;
struct Customer dequeuedCustomer = temp->customer;
queue->front = temp->next;
if (queue->front == NULL){
queue->rear = NULL;
}
free(temp);
return dequeuedCustomer;
}
}
int determineQueueNumber(char firstLetter){
int position = firstLetter -'A';
int queueNumber = position %13;
if (queueNumber ==0){
return 1;
} else {
return queueNumber;
}
}
int main(){
int n, b;
scanf("%d %d", &n, &b);
struct Queue queues[13];
for (int i =1; i <=12; i++){
initializeQueue(&queues[i]);
}
for (int i =0; i < n; i++){
struct Customer customer;
scanf("%s %d %d", customer.name, &customer.tickets, &customer.arrivalTime);
int queueNumber = determineQueueNumber(customer.name[0]);
enqueue(&queues[queueNumber], customer);
}
for (int i =1; i <= b; i++){
// Print booth header
printf("Booth %d
", i);
for (int j =1; j <=12; j++){
}
printf("
");
}
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions