Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a complete C program - you must declare and use a self-referential structure for this question Code include book list This task is to

Write a complete C program - you must declare and use a self-referential structure for this question

image text in transcribedimage text in transcribedimage text in transcribed

Code include book list

This task is to develop a software for a bookshop that handles the purchases through online. When the customer places order to buy a book, the shop will search for the specific item upon customers request in the order of first come first served basis. The books available in the shop are kept in a text file called books.txt. At the beginning of the program the details of the books are read from books.txt and stored in a Linkedlist. Then the list of the books 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 book in a stack to be able to retrieve for the last book sold. The main() function handles all interactions with the user and other functions: Calls a function named readBook()which opens a text file books.txt (a sample text file is shown below) for reading and storing names of books 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 books-here you display the contents of the Linkedlist (2) Add a new book to stock - you need to insert a new book to LinkedList (3) Display next order information - displays the next book 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 book 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 book (top of the stack) back into LinkedList (book 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 book file - updates the books.txt with the remaining books in the list (including the books added in option2). (10) Quit program Sample books.txt file books.txt - Notepad File Edit Format View Help 1991 The God of Small Things 1002 Harry Potter and the Goblet of Fire 1003 A Brief History of Time 1004 Sapiens: A Brief History of Humankind 1005 Love in the Time of Cholera 1006 Shuggie Bain 1007 A Brief History of Seven Killings 1008 To Kill a Mockingbird 1999 The Count of Monte Cristo 1019 David Copperfield 1011 The Scarlet Letter 1012 Alice's Adventures In Wonderland 1013 The Portrait of a Lady 1014 Three Men in a Boat 1015 The Thirty-Nine Steps

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

Students also viewed these Databases questions