luejack Library is one of the popular libraries in the town. This library has more than 50.000 books. Sadly the senior librarian wants to resign and he doesn’t have time to teach the new librarian. Bluejack Library needs a simple program to help the new librarian so he can easily manage and search books. Bluejack Library hires you as a programmer to help them create a program that can help a new librarian find and manage books in this library easily using a C programming language and hashtable data structure. The criteria of the program are: The program consists of 4 menus, there are: View Book Insert Book Remove Book Exit If the user chooses View Book (Menu 1), then:
Subject : Data Structure
Language : C
Topic : Hash Table
Sub Topic :
- Pop
- Push
- Search
Case :
Bluejack Library is one of the popular libraries in the town. This library has more than 50.000 books. Sadly the senior librarian wants to resign and he doesn’t have time to teach the new librarian. Bluejack Library needs a simple program to help the new librarian so he can easily manage and search books. Bluejack Library hires you as a programmer to help them create a program that can help a new librarian find and manage books in this library easily using a C programming language and hashtable data structure. The criteria of the program are:
- The program consists of 4 menus, there are:
- View Book
- Insert Book
- Remove Book
- Exit
- If the user chooses View Book (Menu 1), then:
* If there is no book, then show “There is no book(s) !” message
* Otherwise, the program will show all the book data
- If the user chooses Insert Book (Menu 2), then:
- The program will ask user to input the following data:
* Book Title
* Validate Book Title must be between 5 and 50 characters
* Validate Book Title must be unique
* Book Author
* Validate Book Author must start with “ “ or “Mrs. “ and its length must be between 3 and 25 characters
* ISBN
* Validate ISBN must be numeric and its length must be between 10 and 13 digits
* Page Number
* Validate Page Number must be at least 16
- After that, the program will generate a unique id for the inputted book data. The format will follow the following formula:
[Book ID] : [BXXXXX]-[ISBN]-[A][T]
X: The last inserted Book Id number increased by 1
A: The first character of Book Author in uppercase format
T: The first character of Book Title in uppercase format
For example:
The last inserted Book Id is B00001-0123423123-JH
Then the newly inserted Book Id will be B00002-……
- Then, the program will store the inputted new book data to the next item of the last item of the chaining hash table with size 1007 using the following hash function
Key = SUM % SIZE
Key : the hash table index that will store the data
SUM : The sum of the ascii from Book Id
SIZE : The size of the hash table (1007)
Example:
Book Id : B00001-0123423123-JH
SUM : 1044
Size : 1007
Key : 1044 % 1007 = 37
Then the book data will be stored at index 37 of hash table
- If user chooses Remove Book (Menu 3), then:
- The program will ask user to input a Book ID
* Validate if the inputted Book ID doesn’t exists then show “Book not found”
* Otherwise, show the book data and ask the user for confirmation. Validate input must be either “y” or “n”
- If user chooses “y”, then delete the data
- Otherwise, if user chooses “n” return back to main menu
- If user chooses Exit (Menu 4), then terminate the program
Step by step
Solved in 2 steps