Question
C++ You are to write a program for a network of public libraries to keep track of books available at each of the branches. Each
C++
You are to write a program for a network of public libraries to keep track of books available at each of the branches. Each branch has one string as its name. Each branch keeps its books in a linked list in lexicographical order by author's name. Books of the same author are arranged in lexicographical order by title. There may be many copies of the same book in a library branch.
The data structure to be used should be an array of structures, with the structure containing a branch_name field (string) followed by a pointer field.
The pointer field should point to an ordered linked list of the books in that branch. Each node of the linked list corresponds to a book and is a structure with an author_name field, a book_title field, a num_copies field which indicates how many copies of that book are available for checkout, and a pointer field pointing to the next book in the branch.
When a book is checked out from a branch, it is deleted from the branch's linked list. When it is returned to a branch, it is inserted in the appropriate place in the ordered list. A book can be returned to a different branch than the one it was checked out from.
Customers can ask to find how many books of a specific author and title are available in a given branch.
Your program should be menu driven with the menu containing the following options:
1. Create a branch and insert its books. (for each branch, the user creates the list of all books contained in the branch by repeated choice of menu choice number 1, as shown below. S/he inputs the first and last name of author, followed by the title. If more than one copy, each copy has to be added individually. When all books have been inserted to the branch, the user is to type none none none, and go to insert books into the next branch. Only after the whole library database has been created for all branches, the user will venture into menu choices 2 and higher).
2. Give an author name (first, last) and a branch name, to CHECKOUT that book from the branch, (if there is at least one copy of the book available, otherwise print that the branch holds no such book).
3. Give an author name (first, last), a title and a branch name, to RETURN that book to the branch.
4. Give an author name (first, last), a title and a branch name, to FIND the number of copies of that book that are available in that branch (returns zero if there are none).
5. Give a branch name, to PRINT the author name (first, last) and title of all books contained in that branch.
6. Give a branch name and an author name, to FIND the number of books by that author contained in the branch.
7. Give an author name (first, last), to FIND the number of books by that author contained in all the branches of the library system.
8. Give an author name (first, last), to PRINT in lexicographical order the titles of all books by that author contained in all the branches of the library system.
9. Exit the program.
------
When the user chooses menu choice 1, the following dialogue for input of data should ensue:
What is your menu choice?
1
What is the name of the branch?
ALPHA
What is author and title of book?
JOHN SMITH FREEDOM
What is author and title of book?
MICHAEL JONES LIFE ADVENTURES
What is author and title of book?
NONE NONE NONE
Thank you, I created branch ALPHA
...menu is displayed again...
What is your menu choice?
1
What is the name of the branch?
BETA
What is author and title of book?
NAJ GUPTA ALGORITHMS
What is author and title of book?
NAJ GUPTA ALGORITHMS
What is author and title of book?
LEV LAGOS GENIUS
What is author and title of book?
NONE NONE NONE
Thank you, I created branch BETA
...menu is displayed again...
What is your menu choice?
7
Give an author name (first, last), to FIND the number of books by that author contained in all the branches of the library system.
LEV LAGOS
There are 1 books in the library system by LEV LAGOS
What is your menu choice?
2
Give author, title and branch from which to checkout the book:
LEV LAGOS GENIUS BETA
Thank you! The book GENIUS by LEV LAGOS has been checked out from BETA
...menu is displayed again...
What is your menu choice?
7
Give an author name (first, last), to FIND the number of books by that author contained in all the branches of the library system.
LEV LAGOS
There are 0 books in the library system by LEV LAGOS
What is your menu choice?
4
Give an author name (first, last), a title and a branch name, to FIND the number of copies of that book that are available in that branch (returns zero if there are none).
LEV LAGOS GENIUS BETA
There are 0 books in the library branch BETA by LEV LAGOS titled GENIUS
What is your menu choice?
2
Give author, title and branch from which to check out the book:
MATTHEW JONES LIFE ADVENTURES ALPHA
Thank you! The book LIFE ADVENTURES by MATTHEW JONES has been checked out from ALPHA
...menu is displayed again...
What is your menu choice?
3
Give author, title and branch to which book is to be returned:
LEV LAGOS GENIUS APLPHA
Thank you! The book GENIUS by LEV LAGOS has been returned to branch ALPHA
...menu is displayed again...
What is your menu choice?
2
Give author, title and branch from which to checkout the book:
JOE JONES LIFE ALPHA
Sorry! This book is not available at branch ALPHA
...menu is displayed again..
What is your menu choice?
4
Give an author name (first, last), a title and a branch name, to FIND the number of copies of that book that are available in that branch (returns zero if there are none).
LEV LAGOS GENIUS ALPHA
There are 1 books in the library branch ALPHA by LEV LAGOS titled GENIUS
...menu choice is displayed again...
what is your menu choice?
5
Give a branch name, to PRINT the author name (first, last) and title of all books contained in that branch.
BETA
The books in BETA are:
ALGORITHMS by NAJ GUPTA number of copies 2
...menu is displayed again...
What is your menu choice?
9
Thank you and goodbye.
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