Question: CS 2 0 1 Spring 2 0 2 3 - 2 0 2 4 Homework 5 Book Management System Due May 3 1 st ,
CS Spring
Homework
Book Management System
Due May
st
Friday, :Sharp Deadline
Introduction
In this homework, you will explore objectoriented programming by implementing a C
program designed to manage a collection of books. This task involves creating and manipulating
objects, handling user input, and displaying information.
Objective
Your task is to develop a C program that allows users to add new books, display all books, and
search for books by title stored in a designated vector. You will use your knowledge of classes,
vectors, and function implementation to achieve accurate results.
Inputs, Flow of the Program, and Outputs
Inputs:
Book Information: The user will input the title, author, year of publication, and the
number of pages for each book.
User Commands: After adding books, the user can input commands to display all books
or search for a book by title.
Flow of the Program:
Program Initialization: Display a greeting and a menu of possible actions.
User Interaction:
Prompt the user to choose an action eg add a new book, display all books,
search for a book by title, exit the program
Perform the requested action and display the result.
Allow the user to exit the program by choosing the corresponding menu option.
Closure: Terminate the program when the user decides to exit.
Outputs:
Book Information: Displayed in a userfriendly format.
Search Results: Display the information of the book if found, otherwise display a
message.
Confirmation Messages: Upon successful book addition.
Provided Files
book.h: Contains the definition of the Book class.
Required Files to Submit
main.cpp: Contains the main program logic. Implements the main logic to interact with
the user, add books, display books, and search for books by title. The vector of books
should be sorted by author names before displaying. You will need to sort and search
the vectors of Books HINT: add a function void sortBooksvector & a
int size to sort the vector of books by author. For the sorting function, you can
modify the function on slide of vectorspptx under week in the SUCourse.
book.cpp: Contains the implementation of the Book class member functions.
a Member functions to implement:
Constructor: Initialize the book object with provided title, author, year,
and pages.
Getter Member Functions: Return the respective attributes of the book.
printInfo: Display the book's information.
Notes:
You need to write your book.cpp implementation file based on the book.h file provided.
Ensure that the function names and signatures match those in book.h You need to
submit book.cpp but do not submit book.h as it is already provided. The file name
should be bookcpp
You can use cin.ignore; after getting input in both main and the addBook
function to ignore the newline character left in the buffer.
IMPORTANT!
If your code does not compile, then you will get zero. Please be careful
about this and double check your code before submission.
Note: Please avoid using cin.get in your code for your assignment.
We are using CodeRunner, and these functions may cause unexpected
behaviour.
VERY IMPORTANT!
Your programs will be compiled, executed and evaluated automatically; therefore you
should definitely follow the rules for prompts, inputs and outputs. You can check the
example test case outputs from SUCourse to get more information about the expected
output.
Order of inputs and outputs must be in the mentioned format.
Following these rules is crucial for grading, otherwise, our software will not be able to
process your outputs and you will lose some points in the best scenario.
Sample Runs
Below, we provide only one sample run of the program that you will develop, for more sample
runs please check the SUCourse example test cases.
The italic, bold and yellow highlighted phrases are inputs taken from the user.
NOTE THAT these inputs and the newlines after the inputs are missing at SUCourse in the
outputs expected from you, so please ignore this as you copypaste your C code from
VSXCode to SUCourse, the same will happen to your code too. You can see samples of
SuCourse output in your assignment on SuCourse.
Visual StudioXCode Outputs
Sample Run
Menu:
Add a new book
Display all books
Search for a book by title
Exit
Enter your choice:
Enter title: To Kill a Mockingbird
Enter author: Harper Lee
Enter year:
Enter pages:
Menu:
Add a new book
Display all books
Search for a book by title
Exit
Enter your choice:
Exiting...
Sample Run
Menu:
Add a new book
Display all books
Search for a book by title
Exit
Enter your choice:
Enter title:
Enter author: George Orwell
Enter year:
Enter pages:
Menu:
Add a new book
Display all books
Search for a book by title
Exit
Enter your
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
