Question: 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 anduse a self-referential structure for this question (8 Marks) You are askedto write a program for a computer shop that handles the purchasesthrough online. When the customer places order to buy a computer, theshop will search for the specific item upon customers request in theorder of first come first served basis. The items (computer/laptops) available inthe shop are kept in a text file called computers.txt. At thebeginning of the program the details of the computers are read from

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 is saved 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 computers.txt file computers.bst - Notepad File Edit Format View Help Dell Inspiron Dell G7 Lenovo ThinkPad Lenovo X1 Dell Alienware Acer Spin AS us Vivobots HP Spectre Lenova Yoga Samsung Galaxy Asus Zenbook Lenovo Ideapad HP Pavilion MacBook Air MACBook Pro (10) *Qn3_Sample_run - Notepad File Edit Format View Help 5 Please enter customer name: Peter Please enter name of Computer to order: Dell G10 Sorry, Computer Dell 610 is currently out of stock. Order not placed. 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 Display info of last order (9) Update computer file Quit program 5 Please enter customer name: Lilly Please enter name of Computer to order: Dell G7 Computer order for Dell G7 was successfully placed. 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 8 No orders have been processed. 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 In 1, Col 1 100% Windows (CRLF) UTF-8 3:48 PM 12/28/2020 Type here to search 19 *Qn3_Sample_run - Notepad File Edit Format View Help (9) - Update computer file (10) - Quit program 4 ALL ORDERS 1 ID NAME Computer | 1 | Lilly Dell G7 | 2 | Alex | Lenovo X1 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 | Computer Name | Acer Spin Asus Vivobook Asus Zenbook Dell Alienware Dell G7 Dell Inspiron HP Pavilion HP Spectre | Lenova Yoga Ln 190, Col 26 100% Windows (CRLF) UTF-8 3:48 PM 12/28/2020 Type here to search 19 *Qn3_Sample_run - Notepad File Edit Format View Help (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 4 | ALL ORDERS 1 ID 1 NAME Computer | 2 Alex Lenovo X1 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 8 LAST ORDER ID NAME Computer | 1 | Lilly Dell G7 Ln 190, Col 26 100% Windows (CRLF) UTF-8 3:49 PM Type here to search EI 19 12/28/2020 *Qn3_Sample_run - Notepad File Edit Format View Help 5 Please enter customer name: Peter Please enter name of Computer to order: Dell G10 Sorry, Computer Dell 610 is currently out of stock. Order not placed. 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 5 Please enter customer name: Lilly Please enter name of Computer to order: Dell G7 Computer order for Dell G7 was successfully placed. 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 8 No orders have been processed. *Qn3_Sample_run - Notepad File Edit Format View Help (9) Update computer file (10) - Quit program 4 | ALL ORDERS 1 | ID NAME Computer | | 1 | Lilly | Dell G7 I | 2 Alex | Lenovo X1 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 | Computer Name | Acer Spin Asus Vivobook | Asus Zenbook Dell Alienware | Dell G7 | Dell Inspiron HP Pavilion HP Spectre | Lenova Yoga

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!