902 Harry Potter наггу 303 A Brief Histo

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
*books.txt - Notepad
File Edit Format View Help
1001 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
1009 The Count of Monte Cristo
1010 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
Transcribed Image Text:*books.txt - Notepad File Edit Format View Help 1001 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 1009 The Count of Monte Cristo 1010 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
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
Transcribed Image Text: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 Linked List 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
Transcribed Image Text: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 Linked List 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
Expert Solution
steps

Step by step

Solved in 2 steps with 10 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY