PROG12974

  

Requirements
PROG12974 Assignment 4
Sheridan Institute of Technology & Advanced Learning
Faculty of Applied Science and Technology
School of Applied Computing
PROG 12974 – Introduction to Programming (C)
Assignment 4 – Book Manager
In this assignment, you will write a simple Book Manager using C structures and C file processing. The program can do the followings:
REQ-0. Show a Main menu and read a digit from the keyboard. If the digit is not 0-6, then show an
 Error message; If the digit is “0”, then Exit the program. Example I/O:
====== MAIN ======
 0 – Exit Program
 1 – List all Books
 2 – List Books in Categories
 3 – Add a New Book
 4 – Update a Book
 5 – Delete a Book
 6 – Search a Book by ID
==================
Enter your choice: 7
== Incorrect choice!
… …
Enter your choice: 0
== Thank You, Bye-Bye!
REQ-1. If the digit is “1”, show a list of all the books you have, including the book ID, Category, Title, Author, and a short Note. Example I/O:
… …
Enter your choice: 1
——————————————
ID: 1
Category: Novels
Title: Catch-22
Author: Joseph Heller
Note: Not read yet
——————————————
ID: 2
Category: Novels
Title: The Stranger
Author: Albert Camus
Note: Great book!
1
——————————————
ID: 3
Category: Novels
Title: Great Expectations
Author: Charles
Note: Half way to go
——————————————
ID: 4
Category: Languages
Title: ENG4U Notes
Author: Myself
Note: Just for memory
——————————————
REQ-2. If the digit is “2”, then read a Category number and show the list of books in that category.
Example I/O for listing all books in category “Languages”:
… …
Enter your choice: 2
——————————————
List Books by Categories
 1 – Arts
 2 – Languages
 3 – Computers
 4 – Novels
 5 – Others
——————————————
Enter category to list ( 1 – 5 ): 2
——————————————
ID: 4
Category: Languages
Title: ENG4U Notes
Author: Myself
Note: Just for memory
——————————————
REQ-3. If the digit is “3”, show prompt and read book information from the keyboard. The new book is added to the collection. Example I/O for adding new book #5:
… …
Enter your choice: 3
== Enter new book ID ( 1 – 100 ): 1
== Book #1 already exists.
… …
Enter your choice: 3
== Enter new book ID ( 1 – 100 ): 5
——————————————
Enter Category Number [1-Arts; 2-Languages; 3-Computers;4-Novels; 5-Others]: 3
Enter Book Title: C Programming
Enter Author Name: Internet
Enter Note: Online Resources and Links
——————————————
REQ-4. If the digit is “4”, read a book ID, show prompt and read new information to update the existing record. Example I/O for updating book #3:
… …
Enter your choice: 4
== Enter book ID to update ( 1 – 100 ): 6
== Book I#6 does not exist.
… …
Enter your choice: 4
== Enter book ID to update ( 1 – 100 ): 3
——————————————
ID: 3
Category: Novels
Title: Great Expectations
Author: Charles
Note: Half way to go
——————————————
——————————————
Enter Category Number [1-Arts; 2-Languages; 3-Computers;4-Novels; 5-Others]: 4
Enter Book Title: Great Expectations
Enter Author Name: Charles Dickens
Enter Note: Finished 17/11/11
——————————————
REQ-5. If the digit is “5”, read a book ID, show prompt to confirm deleting the book, and delete the book when confirmed. Example I/O for deleting book #1:
… …
Enter your choice: 5
== Enter book ID to delete ( 1 – 100 ): 10
== Book #10 does not exist.
… …
Enter your choice: 5
== Enter book ID to delete ( 1 – 100 ): 1
——————————————
ID: 1
Category: Novels
Title: Catch-22
Author: Joseph Heller
Note: Not read yet
——————————————
Are you sure (Y/N): y
== Book deleted.
REQ-6. If the digit is “6”, read a book ID and show the information of the book. Example I/O:
… …
Enter your choice: 6
== Enter book ID to search ( 1 – 100 ): 10
== Book ID #10 has no information.
… …
Enter your choice: 6
== Enter book ID to search ( 1 – 100 ): 4
3
Tips
——————————————
ID: 4
Category: Languages
Title: ENG4U Notes
Author: Myself
Note: Just for memory
——————————————
1. Read carefully code examples in Chapter 11, especially those for random-access file processing (11.10, 11.11, 11.14, and in particular 11.15). Make sure you fully understand all the examples
before starting.
2. Define 6 functions for the 6 requirements REQ#1 to REQ#6.
3. Your program should be able to test if there is already an existing file containing some book
information. If there is, use it but do not overwrite it; otherwise, create a new file.
4. Consider using the test data file “assignment4_test_data.txt” to test your program. In Windows you can use the following command lines.
D:PROG12974Assignment>assignment4_sun < assignment4_test_data.txt
D:PROG12974Assignment>assignment4_sun < assignment4_test_data.txt > output.txt
From a Linux terminal you can do it like this:
username$> cat assignment4_test_data.txt | ./assignment4.out > output.txt
5. Do NOT use goto statement or recursive functions. Global arrays and structure definition are
acceptable.
Grading
Your submission will be evaluated based on the following criteria:
Submission 1 Submission is in correct format (see instructions below).
Compilation 1 Program compiles without errors (warnings are acceptable).
Documentation 2 Code is well-commented and clearly explained.
Readability 2 Code is clean, well-organized, and easy to follow.
Efficiency 4 Code uses the best approach and is efficient.
Specifications 30 Program works correctly and meets the requirements.
 REQ-0 2
 REQ-1 2
 REQ-2 4
 REQ-3 6
 REQ-4 6
 REQ-5 6
 REQ-6 4
Total Marks 40
*. Penalties may apply to cases when code doesn’t compile, wrong submission or naming, program
crashes while being tested, late submission, submission instructions not followed, use of goto, etc.
Submission
Submit your source code as “assignment4_lastname.c” to the SLATE Assignment 4 submission folder.
If you have your own header file (the .h file), remember to submit the header file as well.
Important Notes
 This is an individual work and is subject to the school Policy on Academic Honesty. The policy is available at: https://policy.sheridanc.on.ca/.
 Submission implies permission of the Faculty to check the submission electronically for plagiarism using
software similarity detecting systems.
 All assignments are subject to a late penalty of 10% per day (including weekends).
 Late assignments will only be accepted up to 3 days after the due date (including weekends).

 

Tags: No tags