Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solve this question using C programming language. Thank you. 3. Write a program to simulate the following scenario. You should use the file queue.h
Please solve this question using C programming language. Thank you.
3. Write a program to simulate the following scenario. You should use the file queue.h defined in the lecture notes. There is a supermarket that has only 3 cashiers, numbered 0,1 and 2 . Therefore, in general, customers form three queues, waiting to check out in front of each of these three cashiers. For simplicity, we assume that at most one customer comes to check out every minute. When a customer comes, he will first check which of these three queues is the shortest, and will then join the shortest queue. If a customer finds that there are two queues of the same length, then he will prefer cashier 0 to cashier 1 , and cashier 1 to cashier 2 , because cashier 0 is the closest to the exit. A cashier is a structure of the following type: The input to the program is read from a file. The first line in the file specifies the typedef struct cashier \{ int numberofCustomersServed; int totalCheckoutTime; float totalAmountReceived; queueADT customerQueue; information of the customer who comes in the first minute; the second line specifies the information of the customer who comes in the second minute, and so on. An empty line indicates that no customer comes in that minute. Each line contains two numbers. The 3 cashierT; Finally, the three cashiers should be implemented as an array: goods he buys. There are one or more spaces between these two numbers. For example, if the file contains only the following five lines: Then it means that there are totally 4 customers: the first comes in the first minute, the second in the second minute, etc., and no customer comes in the fourth minute. The first customer will need to spend 3 minutes checking out (so he will leave the cashier just before the 4th minute), and he will need to pay $10.9; the second customer will need to spend 1 minute checking out (so he will leave the cashier just before the 3rd minute), and he will need to pay $2.1, and so on. There are no more customers after the fourth customer (who comes in the fifth minute), as we have reached the end of input file. Write a program that reads an input file (file name is "supermarket.dat"). The total number of lines in the input file is not known in advance. The program performs the simulation, and outputs the following information - The average time a customer needs to wait after he joins a queue until he starts to check out. - The total amount of money each of the cashiers receives. - The total number of customers each of the cashiers serves. You should represent a customer as a structure, the type of which is defined asStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started