Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THERE ARE SIMILAR QUESTIONS ALREADY ANSWERED ON CHEGG BUT THERE ARE SOME DIFFERENCES PLEASE DO NOT REPOST ALREADY EXISTING ANSWER. I have only posted one

THERE ARE SIMILAR QUESTIONS ALREADY ANSWERED ON CHEGG BUT THERE ARE SOME DIFFERENCES PLEASE DO NOT REPOST ALREADY EXISTING ANSWER.

I have only posted one question as per the rules of chegg. Its just that this question is really long.

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

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

image text in transcribed

All information given in the question has been provided

books.txt - Notepad File Edit Format View Help 1881 The God of Small Things 1802 Harry Potter and the Goblet of Fire 1803 A Brief History of Time 1004 Sapiens: A Brief History of Humankind 1805 Love in the Time of Cholera 1886 Shuggie Bain 1897 A Brief History of Seven Killings 1988 to kill a Mockingbird 1999 The Count of Monte Cristo 1010 David Copperfield 1011 The Scarlet Letter 1912 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

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

i need 7 7 .

Answered: 1 week ago