Question: CS 2 0 1 Spring 2 0 2 3 - 2 0 2 4 Homework 5 Book Management System Due May 3 1 st ,

CS201 Spring 2023-2024
Homework 5
Book Management System
Due May 31
st
, Friday, 22:00(Sharp Deadline)
Introduction
In this homework, you will explore object-oriented 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:
1. Book Information: The user will input the title, author, year of publication, and the
number of pages for each book.
2. 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:
1. Program Initialization: Display a greeting and a menu of possible actions.
2. User Interaction:
Prompt the user to choose an action (e.g., 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.
3. Closure: Terminate the program when the user decides to exit.
Outputs:
Book Information: Displayed in a user-friendly 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
1. 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 sortBooks(vector & a,
int size) to sort the vector of books by author. For the sorting function, you can
modify the function on slide 27 of vectors3.pptx under week 12 in the SUCourse.)
2. 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:
1. 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 book.cpp.
2. 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 copy/paste your C++ code from
VS/XCode to SUCourse, the same will happen to your code too. You can see samples of
SuCourse output in your assignment on SuCourse.
Visual Studio/XCode Outputs
Sample Run 1
Menu:
1. Add a new book
2. Display all books
3. Search for a book by title
4. Exit
Enter your choice: 1
Enter title: To Kill a Mockingbird
Enter author: Harper Lee
Enter year: 1960
Enter pages: 281
Menu:
1. Add a new book
2. Display all books
3. Search for a book by title
4. Exit
Enter your choice: 4
Exiting...
Sample Run 2
Menu:
1. Add a new book
2. Display all books
3. Search for a book by title
4. Exit
Enter your choice: 1
Enter title: 1984
Enter author: George Orwell
Enter year: 1949
Enter pages: 328
Menu:
1. Add a new book
2. Display all books
3. Search for a book by title
4. Exit
Enter your

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!