ISBN Index Solution

$30.00 $24.90

Description

If you’re familiar with books, then you’re probably familiar with an ISBN. ISBN is an acronym for International Standard Book Number. In many countries, an ISBN agency exists to assign a unique ISBN to each book that is published in that country. By doing so, the vast majority of books that get published internationally can be identified by a single, unique ISBN, and this makes it easy for anyone to describe or locate a book, simply by knowing its ISBN.

Assignment

Your program will gather, record, and return a collection of book titles, each identified by the book’s ISBN. Your program will feature a very simple menu that allows the user to perform any one of four operations, one at a time, repeatedly until the user chooses to quit the program. When prompted, the user may select one of the four operations by inputting a unique letter corresponding to one of the operations. The four operations (and their unique letters) are:

[r] Record a Book: This operation asks the user for two pieces of information, an ISBN and a book title. Your program will record the book’s title and associate it to the given ISBN. Use a dictionary for this. You should assume that the ISBN is unique, and if a book was previously recorded using this ISBN, simply disregard the old record and replace it with the new one.

[f] Find a Book: This operation asks the user for one piece of information: an ISBN. Your program will attempt to find an existing record with this ISBN. If found, print the book title associated to this ISBN. If not found, print a message indicating that no such book could be found.

[l] List all Books: This operation does not ask the user for any additional information. Your program will immediately print a list of all known ISBN records, one per line. Each line should contain the ISBN followed by the book title that is associated to the ISBN.

[q] Quit: When this operation is selected, your program will print a friendly goodbye message to the user and then terminate.

Something else? If the user enters a different letter or phrase, print a message informing the user that this option is invalid, and allow them to try again.

Extra Challenges

Add a bit of friendliness to your program! When your program first starts, before the menu options are first printed, display a brief message explaining your program and how to use it.

Because this assignment does not require you to save the ISBN records to a file, you may assume that all records will be lost when the program quits. However, wouldn’t it be useful if the records were not lost? Consider upgrading your program to write all records to a file just before the program quits, and then also load any records from the same file when the program is started again.

Hints

Before starting, practice using dictionaries. You’ll need to know how to create a dictionary, set a value by key, retrieve a value by key, check if a key exists and iterate through all keys and their values.

Sample

Program execution:

What would you like to do?

[r] Record a Book

[f] Find a Book

[l] List all Books

[q] Quit

Enter an option: r

Enter an ISBN: 978-0439708180

Enter a book title: Harry Potter and the Sorcerer’s Stone

Book saved!

What would you like to do?

[r] Record a Book

[f] Find a Book

[l] List all Books

[q] Quit

Enter an option: r

Enter an ISBN: 978-0439023528

Enter a book title: The Hunger Games

Book saved!

What would you like to do?

[r] Record a Book

[f] Find a Book

[l] List all Books

[q] Quit

Enter an option: f

Enter an ISBN: 978-0439023528

Book found: The Hunger Games

What would you like to do?

[r] Record a Book

[f] Find a Book

[l] List all Books

[q] Quit

Enter an option: f

Enter an ISBN: 978-0439708180

Book found: Harry Potter and the Sorcerer’s Stone

What would you like to do?

[r] Record a Book

[f] Find a Book

[l] List all Books

[q] Quit

Enter an option: l

1) 978-0439023528: The Hunger Games

2) 978-0439708180: Harry Potter and the Sorcerer’s Stone

What would you like to do?

[r] Record a Book

[f] Find a Book

[l] List all Books

[q] Quit

Enter an option: x

Sorry, that option is invalid.

What would you like to do?

[r] Record a Book

[f] Find a Book

[l] List all Books

[q] Quit

Enter an option: q

Bye! See you next time!