CSc 3320 System-Level Programming
Fall 2000
Homework #3
Due: 25 October 2000 (Wednesday)
Write a csh script which manages a book library database. The script should allow the user to add books to the database, check in/out a book, display books, print sorted reports and delete books. The script should be menu-based with the following options:
Main Menu: (e) Edit Submenu (r) Report Submenu (q) Quit Edit Submenu: (a) Add a book (p) Display a book (i) Checkin book (o) Checkout book (d) Delete a book (q) Return to Main Menu Report Submenu: (a) Sort by Author (t) Sort by Title (c) Sort by Status (q) Return to Main MenuEach book entry should consist of a Title, Author, Status, Borrower's name, and Check Out date. The status of a book could be in or out. The check out date and borrower's name would be empty if the status of a book is in.
The book entries must be kept in a text file (called .books) in the user's home directory with the following format:
Oracle Programming:Sunderraman:in:: Database Systems:ElMasri:out:12/5/99:Jones Java Programming:King:out:10/12/99:SmithThe title of the book serves as the primary key, i.e. we cannot have two books with the same title.
The options within the Report submenu should produce a well formatted listing of the books.
Each of the sub-options in the Edit sub-menu should interact with the user as follows:
(a) Add a book: should prompt the user for the following: Book Title: Author: This option should check to see if there is a book with the same title; If present, an error message should be generated otherwise the book should be added to the database. (p) Display a book: should prompt the user for the book title: Book Title: After reading the book title, this option should verify if the book is present in the database; If not present an error message should be generated otherwise the book should be displayed in a nice format. (i) Checkin book: should prompt the user for the book title: Book Title: After reading the book title, this option should verify that the book exists and that it is checked out. If so, then the status should be changed in the database, otherwise an error message should be generated. (i) Checkout book: should prompt the user for the book title and borrower's name: Book Title: Borrower: After reading the book title and name, this option should verify that the book exists and that it is checked in. If so, the status should be changed in the database, otherwise an error message should be generated. The system date should be used to update the checkout date. (i) Delete book: should prompt the user for the book title: Book Title: After reading the book title, this option should verify that the book exists and that it is not checked out. If so, then the book entry should be deleted in the database, otherwise an error message should be generated.
Each of the sub-options in the Report sub-menu should interact with the user as follows:
(a) Sort by Author: should print a well formatted listing sorted by author name of all the books in the database. Try to fit a few entries per screen and allow user to hit enter key to view next page. (t) Sort by Title: same as (a) but sorting is on title. (c) Sort by Status: same as (a) but sorting is on status (in or out); List all out books first then in books.