Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c language please 3. You must create a struct to store a queue of customers. This struct should have two pointers one to the

in c language please

image text in transcribedimage text in transcribed

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% The Output (to be displaved in the standard console output (no file i/o)) For each customer, in the order that thev 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

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

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions