Write a Python module that stores books' titles and ISBN(10 digits) in the library first, then perform several operations. The program should print a main menu that gives a list of options. Option 1: Add books to the library The librarian should be able to enter all books by title and unique ISBN space-separated. The ISBN must be unique, ten digits, and should contain numbers only. If the ISBN is not in the required format, or is duplicated, print ‘Invalid entry’ and keep prompting for valid entries until all books are entered.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section: Chapter Questions
Problem 9PP
icon
Related questions
Question

Write a Python module that stores books' titles and ISBN(10 digits) in the library first, then perform several operations.
The program should print a main menu that gives a list of options.

Option 1: Add books to the library
The librarian should be able to enter all books by title and unique ISBN space-separated. The ISBN must be unique, ten digits, and should contain numbers only. If the ISBN is not in the required format, or is duplicated, print ‘Invalid entry’ and keep prompting for valid entries until all books are entered.
Option 2: Print available books in the library
The librarian should be able to print all the available books in the library including the title and ISBN.
Option 3: Create book collections
The librarian should be able to create book collections. The program should first ask for the number of books per collection. Next, prompt the librarian to enter all the books in each collection using the book ISBN until there are no more books left in the library.
Option 4: Sort books in the collections
The librarian should be able to sort the books in a collection by ascending or descending order of ISBN. The program should prompt the librarian for the sorting order.
Option 5: Delete a collection
The librarian should be able to delete a book collection. Once a collection is deleted, it should be added back to the library of available books. If there is no collection available, the program should print ‘Invalid entry’.
Option 6:
The program should quit.

There is an image attached for the minimum required functions for this program, and example output.

A dictionary is recommended for the library. If the total number of books is not a multiple of the collection size, then the last collection will have fewer books.
If the librarian chooses option 2 while there are no books in the library, print ‘Invalid entry’.
A book can be in only one collection.
Books available in the library should change depending on whether collections are created or deleted.
When printing the book title and ISBN, the required alignment is 20 spaces per column. The program should always check all invalid operations.  Print the standard error message ‘Invalid entry’ for invalid operations.

Main Menu........
1. Add books to the library
2. Print available books in the library
3. Create book collections
4. Sort books in the collections
5. Delete a collection
6. Quit
Choose a menu option: 1
How many books would you like to enter: 7
Enter book 1: Gemini 9123055800
Enter book 2: Facial Recognition 9123055810
Enter book 3: C++ Primer 9123055810
Invalid entry
Enter book 3: C++ Primer 9123055820
Enter book 4: Time 9123055830
Enter book 5: Jack in the box 9123064
Invalid entry
Enter book 5: Jack in the box 9123064100
Enter book 6: Nature AT2306510
Invalid entry
Enter book 6: Nature 9123065100
Enter book 7: Genetic Entropy 9123066100
******** Main Menu..
1. Add books to the library
2. Print available books in the library.
3. Create book collections
4. Sort books in the collections
5. Delete a collection
6. Quit
*******
Choose a menu option: 2
Books available in the library:
Gemini
Facial Recognition
C++ Primer
Time
Jack in the box
Nature
Genetic Entropy
9123055800
9123055810
9123055820
9123055830
9123064100
9123065100
9123066100
*********
************Main Menu
1. Add books to the library
2. Print available books in the library
3. Create book collections
4. Sort books in the collections
5. Delete a collection
6. Quit
Choose a menu option: 3
What is the size of the collection? 3
Enter the book ISBNs for collection 1:
9123055800
8123055826
Invalid entry
9123055820
9123064100
Enter the book ISBNs for collection 2:
9123065100
9123055810
9123055830
Enter the book ISBNs for collection 3:
9123066100
Current book collections:
Collection.
Collection 1:
Gemini
Jack in the box
C++ Primer
Collection 2:
Nature
Time
9123055800
9123064100
9123055820
9123065100
9123055830
Facial Recognition 9123055810
Collection 3:
Genetic Entropy
9123066100
*******************Main Menu*******************
1. Add books to the library
2. Print available books in the library
3. Create book collections
4. Sort books in the collections
5. Delete a collection
6. Quit
*******
Choose a menu option: 2
Invalid entry
***********Main Menu***************
1. Add books to the library
2. Print available books in the library
3. Create book collections
4. Sort books in the collections
5. Delete a collection
6. Quit
*********
*******************
Choose a menu option: 4
Sort books in ascending or descending order of ISBN: ascending
Current book collections:
Collection 1:
Gemini
C++ Primer
Jack in the box
Collection 3:
Genetic Entropy
9123055800
9123055820
9123064100
Collection 2:
Facial Recognition 9123055810
Time
Nature
9123055830
9123065100
9123066100
*******************Main Menu
1. Add books to the library
2. Print available books in the library
3. Create book collections
4. Sort books in the collections.
5. Delete a collection
6. Quit
********
Choose a menu option: 5
Which collection would you like to delete? 8
Invalid entry
**************Main Menu**************
1. Add books to the library
2. Print available books in the library.
3. Create book collections
4. Sort books in the collections
5. Delete a collection
6. Quit
Choose a menu option: 5
Which collection would you like to delete? 2
Current book collections:
Collection 1:
Gemini
C++ Primer
Jack in the box
Collection 2:
Genetic Entropy
9123055800
9123055820
9123064100
912306610
***********Main Menu****
1. Add books to the library
2. Print available books in the library
3. Create book collections
4. Sort books in the collections
5. Delete a collection
6. Quit
Choose a menu option: 2
Books available in the library:
Facial Recognition 9123055810
Time
9123055830
9123065100
Nature
**************
*****************
............Main Menu....
1. Add books to the library
2. Print available books in the library
3. Create book collections
4. Sort books in the collections
5. Delete a collection
6. Quit
Choose a menu option: 6
End
**************
Transcribed Image Text:Main Menu........ 1. Add books to the library 2. Print available books in the library 3. Create book collections 4. Sort books in the collections 5. Delete a collection 6. Quit Choose a menu option: 1 How many books would you like to enter: 7 Enter book 1: Gemini 9123055800 Enter book 2: Facial Recognition 9123055810 Enter book 3: C++ Primer 9123055810 Invalid entry Enter book 3: C++ Primer 9123055820 Enter book 4: Time 9123055830 Enter book 5: Jack in the box 9123064 Invalid entry Enter book 5: Jack in the box 9123064100 Enter book 6: Nature AT2306510 Invalid entry Enter book 6: Nature 9123065100 Enter book 7: Genetic Entropy 9123066100 ******** Main Menu.. 1. Add books to the library 2. Print available books in the library. 3. Create book collections 4. Sort books in the collections 5. Delete a collection 6. Quit ******* Choose a menu option: 2 Books available in the library: Gemini Facial Recognition C++ Primer Time Jack in the box Nature Genetic Entropy 9123055800 9123055810 9123055820 9123055830 9123064100 9123065100 9123066100 ********* ************Main Menu 1. Add books to the library 2. Print available books in the library 3. Create book collections 4. Sort books in the collections 5. Delete a collection 6. Quit Choose a menu option: 3 What is the size of the collection? 3 Enter the book ISBNs for collection 1: 9123055800 8123055826 Invalid entry 9123055820 9123064100 Enter the book ISBNs for collection 2: 9123065100 9123055810 9123055830 Enter the book ISBNs for collection 3: 9123066100 Current book collections: Collection. Collection 1: Gemini Jack in the box C++ Primer Collection 2: Nature Time 9123055800 9123064100 9123055820 9123065100 9123055830 Facial Recognition 9123055810 Collection 3: Genetic Entropy 9123066100 *******************Main Menu******************* 1. Add books to the library 2. Print available books in the library 3. Create book collections 4. Sort books in the collections 5. Delete a collection 6. Quit ******* Choose a menu option: 2 Invalid entry ***********Main Menu*************** 1. Add books to the library 2. Print available books in the library 3. Create book collections 4. Sort books in the collections 5. Delete a collection 6. Quit ********* ******************* Choose a menu option: 4 Sort books in ascending or descending order of ISBN: ascending Current book collections: Collection 1: Gemini C++ Primer Jack in the box Collection 3: Genetic Entropy 9123055800 9123055820 9123064100 Collection 2: Facial Recognition 9123055810 Time Nature 9123055830 9123065100 9123066100 *******************Main Menu 1. Add books to the library 2. Print available books in the library 3. Create book collections 4. Sort books in the collections. 5. Delete a collection 6. Quit ******** Choose a menu option: 5 Which collection would you like to delete? 8 Invalid entry **************Main Menu************** 1. Add books to the library 2. Print available books in the library. 3. Create book collections 4. Sort books in the collections 5. Delete a collection 6. Quit Choose a menu option: 5 Which collection would you like to delete? 2 Current book collections: Collection 1: Gemini C++ Primer Jack in the box Collection 2: Genetic Entropy 9123055800 9123055820 9123064100 912306610 ***********Main Menu**** 1. Add books to the library 2. Print available books in the library 3. Create book collections 4. Sort books in the collections 5. Delete a collection 6. Quit Choose a menu option: 2 Books available in the library: Facial Recognition 9123055810 Time 9123055830 9123065100 Nature ************** ***************** ............Main Menu.... 1. Add books to the library 2. Print available books in the library 3. Create book collections 4. Sort books in the collections 5. Delete a collection 6. Quit Choose a menu option: 6 End **************
Function name
print_menu()
check_ISBN()
add_books ()
print_books()
create_collections()
sort_collections()
delete_collection()
main()
Function description
Prints the menu of options to the
librarian
Checks the format of an ISBN
Adds unique books to the library
Prints available books in the library
Creates book collections
Prints sorted books in each
collection
Deletes a collection from the list of
collections and adds it back to the
library
Driver function that calls all the
functions above.
Function input(s)
None
ISBN string
Sequence of books Sequence of
books
Sequence of books
Sequence of books
Function
output(s)/
return value(s)
Menu of options
Sequence of books Sequence of
books
Sequence of books
boolean True or
False
None
Sorted
sequence of
books
Transcribed Image Text:Function name print_menu() check_ISBN() add_books () print_books() create_collections() sort_collections() delete_collection() main() Function description Prints the menu of options to the librarian Checks the format of an ISBN Adds unique books to the library Prints available books in the library Creates book collections Prints sorted books in each collection Deletes a collection from the list of collections and adds it back to the library Driver function that calls all the functions above. Function input(s) None ISBN string Sequence of books Sequence of books Sequence of books Sequence of books Function output(s)/ return value(s) Menu of options Sequence of books Sequence of books Sequence of books boolean True or False None Sorted sequence of books
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning