Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE C EXPERTS COME TO THE RESCUE!! This is the expected output ^ It depends on this input (not file I/O) This is the problem
PLEASE C EXPERTS COME TO THE RESCUE!!
This is the expected output ^
It depends on this input (not file I/O)
This is the problem
1234567891011IMRANchecksoutat1020fromline1.ADAMchecksoutat1710fromline6.CHRISTOPHERchecksoutat4880fromline6.MEHMEDchecksoutat8130fromline1.ORHANchecksoutat104290fromline15.Achecksoutat8150fromline1.Fchecksoutat15800fromline8.Echecksoutat23530fromline5.Dchecksoutat31340fromline4.Cchecksoutat39230fromline3.Bchecksoutat47200fromline2. Problem: MVA Queue in the Monster City Monster city has one Motor Vehicle Administration (MVA) service center that performs various services such as driving license \& ID card issue, renewal, replace, motor vehicles and tags registration, replace, and renew, tax collection, and many other services. In order to save costs, the center is using ONLY ONE CLERK to serve the customers. So, their service is extremely slow. However, to hide the fact that there is really only one checkout line, the center is having customers queue in several lines. Upon arrival at the service center, the customer's time of arrival, last name, line number where the customer is standing, and the number of services to be taken by the customer are recorded and the customer stands in the line to meet the clerk. It also should be noted that whenever a customer is able to meet the clerk, they need to provide information about each services they are taking. So, performing each task takes some time. After the clerk finishes helping a customer, he checks the status of all the lines that are currently queued. Of all the customers at the front of those lines, he'll take the customer who will take the fewest number of services. If there are two customers with the same number of services, he'll take the customer who comes from the smaller line number. The lines are numbered 1 through 15 . It's possible that some of these lines will be empty, in which case these lines are ignored. The number of seconds the store clerk takes to check out a customer is 50 plus 80 times the number of services. Thus, if a customer is taking 8 services, the clerk would check her out in 50+880=690 seconds. The Problem You will write a program that reads in information about customers: which line they go to the back of (1 through 15), at what time (in seconds) they enter that line, and the number of services they will take, and determines at what time each customer will check out. The Input (to be read from standard input using scanf( using file i/o will result in zero in the assignment)) The first line will contain a single positive integer, c(c30), representing the number of test cases to process. The test cases follow. The first line of each test case will have a single positive integer, n(n500,000), the number of customers who are taking services. (Note: there can be 1 or 2 test cases with the maximum number of customers while grading. The rest will be a fair bit smaller.) The following n lines will have information about each customer. These n lines will be sorted from earliest event to latest event. Each of these lines will contain 4 pieces of information. The first item is the name of the customer, a string of 1 to 15 uppercase letters. This is followed by a positive integer, x(x100), representing the number of services the customer is receiving. The next positive integer, t(t109), represents the check-in time of the customer, in seconds, from the beginning of the simulation that the first customer steps into a line. The last number is another positive integer, m(m15), represents which line the customer steps into. It is guaranteed that all of the check-in times are unique and that all of the customer names are unique as well. The Output (to be displayed in the standard console output (no file i/o)) For each customer, in the order that they get checked out, print a single line with the following format: CUSTOMER checks out at T from line X. where CUSTOMER is the name of the customer checking out, X is the line they entered to check out, and T is the number of seconds AFTER the start of the simulation, that they complete checking out. (Thus, this time is the time they get called to cash out, plus the time it takes them to cash out.) Sample Input (in.txt file) Sample Output (should be standard console output) IMRAN checks out at 1020 from line 1. ADAM checks out at 1710 from line 6. CHRISTOPHER checks out at 4880 from line 6. MEHMED checks out at 8130 from line 1. ORHAN checks out at 104290 from line 15 . A checks out at 8150 from line 1 . F checks out at 15800 from line 8 . E checks out at 23530 from line 5 . D checks out at 31340 from line 4 . C checks out at 39230 from line 3 . B checks out at 47200 from line 2 . Implementation Restrictions 1. You must create a struct that stores information about a customer (name, number of services, line number, time entering line). Note that the storage of the line number is redundant, but is designed to ease implementation. Also, you must need to create a function that can create a customer using dynamic memory allocation, fill out the customer and then return the customer. You have to use this function whenever you need to create a customer. 2. You must create a node struct for a linked list of customers. This struct should have a pointer to a customer struct, and a pointer to a node struct. 3. You must create a struct to store a queue of customers. This struct should have two pointers one to the front of the queue and one to the back. 4. You must implement all of the lines that form as an array of size 15 (stored as a constant) of queues. [It is kind of an array of 15 queues, where each queue is a linked list] 5. You must dynamically allocate memory as appropriate for linked lists. 6. Your queue must support the following operations: a. Enqueue b. Dequeue c. Peek: Return the front of the queue WITHOUT dequeuing. d. Empty (returns 1 if the queue is empty, 0 if it is not) 7. You must free memory appropriately. Namely, when you dequeue, you'll free memory for a node, but you will NOT free memory for the customer. You will free this memory a bit later right after you calculate when that customer will finish checking out. 8. You must use the memory leak detector like PA1 and as shown in earlier labs. 9. Due to the nature of the problem, when you process the input, you can add everyone into their appropriate lines right at the beginning, before checking anyone out. This wouldn't work in all simulations (some of which you have to do in time order), but because there is ONLY one check out line, you can get away with it. The only thing you have to be cognizant about is that when you select a line, if the current time is 100 for example, and three lines have customers who arrived before time 100 and the other lines have customers in the front who arrived AFTER time 100, you have to ignore the customers in those lines who arrived after time 100. In the case that all the lines have customers who arrived after time 100, you would take the line which has a customer who arrived first. You are guaranteed no ties for arrival time so this would be unique. Rubric (subject to change): The code will be compiled and tested in codegrade for grading. If your code does not compile in codegrade, we conclude that your code is not compiling and it will be graded accordingly. We will apply a set of test cases to check whether your code can produce the expected output or not. The output format has to match exactly to pass test cases. Failing each test case will reduce some grade based on the rubric given bellow. If you hardcode the output, you will get 200% for the assignment. 1. If a code does not compile: May result in 0 (still you should consider submitting it as we may/may not apply partial credit) 2. If you do not create/write/use the required structures and functions: you may get 0 3. Not writing and using the enqueue, dequeue, and peek function will receive 0 4. There is no grade for a well indented and well commented code. But a bad written/indented code will receive 20% penalty. Not putting comment in some important block of code 10%Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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