Write a class with a main method that uses a priority queue to store a list of chores and the chore's priority. You need to store the name of the chore and it's assigned priority. Assigned priorities can be any positive integer. The rest is up to you. You may use the Java Linked List Class and build your queue with that class.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
Question

The first picture is part 1 and the second picture is pt 2. Please keep the code neat... and add comments. (The comments doesnt need to be long, just keep them short and simple). Please dont do add extra things into the code. Just follow the instructions. Thanks. WRITE in JAVA.

Write a class with a main method that uses a priority queue to store a list of chores and the chore's
priority. You need to store the name of the chore and it's assigned priority. Assigned priorities can
be any positive integer. The rest is up to you.
You may use the Java Linked List Class and build your queue with that class.
Transcribed Image Text:Write a class with a main method that uses a priority queue to store a list of chores and the chore's priority. You need to store the name of the chore and it's assigned priority. Assigned priorities can be any positive integer. The rest is up to you. You may use the Java Linked List Class and build your queue with that class.
You may use the Java Library Queue class for Part 2
Write a program to simulate checkout lines at a grocery store. There will be multiple queues, one for
each checkout line. For this exercise, you may assume there are 5 checkout lines. You can use an
array of queues to simulate the checkout lines.
Use the following logic:
1. Generate 5 customers and enqueue them, one customer in each queue
2. Each new customers ready to check out choose the shortest line
Customers enter the checkout queues randomly, and then each time a customer is generated that
customer chooses the shortest line.
If the lines are equal, then the first available line is chosen. Each transaction takes a random amount
of time to complete. Print each action taken with Queue number, to the display.
For your output show the queues with customers and activity, showing changes in each queue.
You can capture all of the output at the end of the program running. Program should list actions that
have been performed and Queue numbers.
Be sure to limit your program in order to ensure that it does not run forever.
Transcribed Image Text:You may use the Java Library Queue class for Part 2 Write a program to simulate checkout lines at a grocery store. There will be multiple queues, one for each checkout line. For this exercise, you may assume there are 5 checkout lines. You can use an array of queues to simulate the checkout lines. Use the following logic: 1. Generate 5 customers and enqueue them, one customer in each queue 2. Each new customers ready to check out choose the shortest line Customers enter the checkout queues randomly, and then each time a customer is generated that customer chooses the shortest line. If the lines are equal, then the first available line is chosen. Each transaction takes a random amount of time to complete. Print each action taken with Queue number, to the display. For your output show the queues with customers and activity, showing changes in each queue. You can capture all of the output at the end of the program running. Program should list actions that have been performed and Queue numbers. Be sure to limit your program in order to ensure that it does not run forever.
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

There are several things that are wrong with this question. When I type it in my IDE, It comes up as 44 errors. And what exactly is supposed to be the output? You didn't post that.

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning