# COMP – 10205 – Data Structure and Algorithms

You are to write a program that will attempt to optimize the time it takes to process customers in check
out lines inside a grocery store. You will use the Queue data structure for this assignment.
The general idea is to always place customers in the best checkout line possible. This will be based on
the total number of customers and the number of items in each cart being processed. The time to serve
a single customer is calculated by the following formula:
t = 45 + 5*ni;
where: t, time in seconds that it takes to serve a customer,
ni, the number of items in the customers cart.
A store consists of 1 or more checkout lines defined by:
n = number of normal checkout lines
f = number of express checkout lines (less than or equal to x items)
A store could have up to 4 fast checkout lines.
Customers at the store may have many items in their cart or only a few. Each new customer will be
added to the checkout line with the cumulative least amount of time in front of it (the shortest line).
Any customer may optionally enter one of f express lines if they have less than or equal x items in the
cart. It should be noted that they do not need to enter an express line if another checkout line would
result in a shorter service time. Customers with more than x items must enter one of the other n check
out lines in the store. The total number of checkout lines will be equal to n + f;
Example Case
Example Data: x = 10, n = 2, f = 1 and 8 customers and carts come to the checkout in the following
order: 6,7,45,10,11,21,2,4 (the number is the number of items in the cart). You can assume they all
arrive at the checkout at the same time for this lab. When placed into the optimum checkout line the
following checkout lines (queues) will result.

Part A
You need to output your optimum starting case for all of the checkout lines in the store and then
calculate the amount of time it will take for the store to be empty of all customers. Your output must
show each Queue in order. An example output is shown below:

Part B
Simulate the removal of customers from each checkout by servicing the customers. It is suggested you
set up a loop to calculate the state of the Checkout lines after each second, but only display lines every
30 or 60 seconds simulated. Once the amount of time has passed required to service the customer at
the start of the Queue, the customer must be removed and processing will continue with the next
customer. For the above case we would start at time = 0 and continue until time = 330 s at which point
all customers would have been serviced. It is suggested that you not show the output after every
second, but instead after every 30 or 60 seconds. The example below shows every 60 seconds for the
same data that was used in part A. In your solution you must use a simulation step of 30 seconds.

Suggested Steps:
1. Create a new project in IntelliJ.
2. Add the example data (Customer_Example.txt) and evaluation data set (Customer.txt) to the
project.

3.AddatoStringmethod to theLinkedQueue.javathat will print all the items in the Queue on a

single line.
4. Add a new class to the project to hold each Customer. Add a property for the number of items
in the cart and a method to calculate how long it will take to serve a customer and any other
properties and methods you feel are appropriate.
5. Override the toString method to display the contents of the object neatly (in my example the
Customer will print the number of items and the time it will take to serve a customer).
6. Inside the main class you will need to create a LinkedQueue for each of the checkout lines.
You will also need to track the current wait time for each queue.
7. Read the checkout line and customer information from the data file and add them to the
correct Queue.
8. Output your results for Part A and verify the test case and the Customer data case.
9. Solve Part B by using a loop to process all the lines simultaneously one second at a time.
Remove the customer when the loop counter equals the time to process for that checkout line.

Hints
Use the isEmpty() method of the LinkedQueue to decide if queue has customers.
Use the size() method of LinkedQueue to indicate the number of customers in any checkout
line.

NOTE: This is a college-level assignment DO NOT use high-level of programming to write the code. The code should be hand-written DO NOT use any AI tools to write the code. Please read and follow all the instructions carefully. Moreover, I have attached all the screenshots and files for the required information to write the code. Please find it attached!

I have two more files to attach but unable to attach it I’ll attached in the chat.