Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using a Linked List and priority Queue, construct the following C++ program. Define a C++ class for a basic Expense class which contains 3 pieces

Using a Linked List and priority Queue, construct the following C++ program.

image text in transcribed

Define a C++ class for a basic Expense class which contains 3 pieces of info: ID (integer) Amount (double) Priority (integer between 1 and 3) Implement a priority queue data structure with the following public interface: enqueue dequeue Queue requirements: Each queue element is an expense item with priority category of (1) NECESSITY, (2) BUDGETED and (3) OPTIONAL, the expense amount and ID. As a queue, it can only be enqueued at one end and dequeued at the other end with first-in/first-out (FIFO) policy with the exception of priority. A higher priority queue element will always be in the front of the queue before the lower priority one. In another words, if I enqueue an expense item of BUDGETED and then follow by the item of NECESSITY, when I dequeue, I will get the item of NECESSITY as it has higher priority to be processed first. It must use linked list as the implementation data structure for the queue All data members in your classes must be declared as "private" Well structure, easy to understand with the proper use of reusable functions, methods and classes. Write a queue simulation program: Randomly generate a set of expense items (amounts between 100 and 999 along with a priority between 1 and 3 and assigned ID between 1000 to 9999) Create an Item object out of those 3 random generated info and enqueue Once the queue is complete, start dequeuing the Item and print it out. It should be printed in the order of priority. If the elements have the same priority, it should be printed in the order that it is enqueued. Run the test with at least 3 set of separate number generations

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

Microsoft Office 365 For Beginners 2022 8 In 1

Authors: James Holler

1st Edition

B0B2WRC1RX, 979-8833565759

More Books

Students also viewed these Databases questions