Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Qn3. Write a complete C program - you must declare and use a self-referential structure for this question (8 Marks) You are asked to write

Qn3. Write a complete C program - you must declare and use a self-referential structure for this question (8 Marks)

You are asked to write a program for a computer shop that handles the purchases through online. When the customer places order to buy a computer, the shop will search for the specific item upon customers request in the order of first come first served basis. The items (computer/laptops) available in the shop are kept in a text file called computers.txt.

At the beginning of the program the details of the computers are read from computers.txt and stored in a LinkedList. Then the list of the computers ordered by customers issaved in a queue. Then the program should take the order from the beginning (head) of the queue and search for it in the LinkedList. If the item found in the list delete it and put this computer in a stack to be able to retrieve for the last computer sold.

The main() function handles all interactions with the user and other functions:

Calls a function named readList()which opens a text file computers.txt (a sample text file is shown below) for reading and storing names of computers from the file to a LinkedList in order of name (insertion should happen in alphabetical order).

It then repeatedly calls the menu () function to display user options, get the user selection returned by the menu() function, use a switch (or if ..else if) statement to process user request by calling appropriate function(s).

Details of options in menu function:

(1) Display the current stock of computers here you display the contents of the LinkedList

(2) Add a new computer to stock you need to insert a new computer to LinkedList

(3) Display next order information displays the next computer in the order-list (first node of the queue)

(4) Display all orders displays all nodes of the queue

(5) Add order to queue adds new order to the end of the queue

(6) Process the next order Processes the first order in the queue. This function searches for this computer in the LinkedList and deletes (if found) from LinkedList and puts it into a stack, deletes from the queue as well.

(7) Cancel last order It cancels the last processed order. It inserts the computer (top of the stack) back into LinkedList (computer is not added back into queue).

(8) Display info of last order displays the information of the last processed order (top of the stack).

(9) Update computer file updates the computers.txt with the remaining computers in the list (including the computers added in option2).

(10) Quit program

sample run of program

plz note i want ans with output same as sample run of program given below

image text in transcribed

Successfully loaded Computer file. What would you like to do? (1) - Display the current stock (linked-list) (2) - Add a computer to stock (linked-list) (3) - Display next order info (4) - Display all orders (5) - Add order to queue (6) Process the next order (7) Reverse last order (8) - Display info of last order (9) - Update computer file (10) Quit program 1 + 1 Computer Name | | Acer Spin Asus Vivobook | Asus Zenbook | Dell Alienware | Dell G7 | Dell Inspiron | HP Pavilion | HP Spectre | Lenova Yoga | Lenovo Ideapad | Lenovo ThinkPad | Lenovo X1 | MACBook Pro | MacBook Air | Samsung Galaxy What would you like to do? (1) Display the current stock (linked-list) (2) Add a computer to stock (linked-list) (3) Display next order info

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

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

More Books

Students also viewed these Databases questions

Question

5. Tell how job experiences can be used for skill development.

Answered: 1 week ago

Question

4. Explain the characteristics of successful mentoring programs.

Answered: 1 week ago