Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I want get a c programme for this structure and blow you can see sample txt . special i want get screen shots Sample computers.txt
I want get a c programme for this structure and blow you can see sample txt . special i want get screen shots
Sample computers.txt file computers.txt - Notepad File Edit Format View Help Dell Inspiron Dell G7 Lenovo ThinkPad Lenovo X1 Dell Alienware Acer Spin Asus Vivobook HP Spectre Lenova Yoga Samsung Galaxy Asus Zenbook Lenovo Ideapad HP Pavilion MacBook Air MacBook Pro 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 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 2 Please enter Computer name to insert: Lenovo XYZ 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 | Lenovo XYZ MAcBook Pro | MacBook Air | Samsung Galaxy 1 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 3 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 4 There are no orders. 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: Peter Please enter name of Computer to order: Dell G10 Sorry, Computer Dell G10 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) - 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 (3) 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 (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 3 + 1 NEXT ORDER I 1 ID 1 NAME I Computer + | 1 | Lilly | Dell G7 I 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 4 ALL ORDERS | 1 ID NAME | Computer + | 1 | Lilly | Dell G7 | 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: Alex Please enter name of Computer to order: Lenovo X1 Computer order for Lenovo X1 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 3 1 NEXT ORDER ID 1 NAME I Computer | | 1 | Lilly | Dell G7 (2) What would you like to do? (1) Display the current stock (linked-list) 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 ALL ORDERS | ID NAME 1 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 | Lenovo Ideapad | Lenovo ThinkPad | Lenovo X1 | Lenovo XYZ 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 (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 6 Computer order for Lilly was successfully 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 (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 Inspiron | HP Pavilion | HP Spectre | Lenova Yoga | Lenovo Ideapad | Lenovo ThinkPad | Lenovo X1 Lenovo XYZ | 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 (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 3 3 NEXT ORDER 1 ID 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 4 | ALL ORDERS | ID NAME Computer | 2 | Alex | Lenovo X1 | -+ 4 1 ALL ORDERS | ID NAME I 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 8 LAST ORDER | ID NAME I Computer | 1 | Lilly | Dell G7 | 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 6 Computer order for Alex was successfully 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 (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 1 LAST ORDER 1 1 ID 1 NAME I Computer | + - + | 2 | Alex | Lenovo X1 1 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 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 Inspiron | HP Pavilion | HP Spectre | Lenova Yoga | Lenovo Ideapad | Lenovo ThinkPad | Lenovo XYZ | MAcBook Pro MacBook Air | Samsung Galaxy (2) What would you like to do? (1) Display the current stock (linked-list) 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 7 Computer order for Alex was successfully reversed. 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 1 Computer Name I + | Acer Spin Asus Vivobook | Asus Zenbook | Dell Alienware Dell Inspiron | HP Pavilion HP Spectre | Lenova Yoga | Lenovo Ideapad | Lenovo ThinkPad | Lenovo X1 | Lenovo XYZ | 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 (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 3 There are no orders. 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 4 There are no orders. 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 9 Successfully written Computer file. The following Computers remain in the list Successfully written Computer file. The following Computers remain in the list 1 Computer Name | Acer Spin Asus Vivobook | Asus Zenbook | Dell Alienware | Dell Inspiron | HP Pavilion | HP Spectre | Lenova Yoga Lenovo Ideapad | Lenovo ThinkPad | Lenovo X1 | Lenovo XYZ | MACBook Pro | MacBook Air | Samsung Galaxy + The file updated successfully 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 10
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started