Question
In C++ create a database of books that are stored using a vector. Keep track of the author, title, and publication date of each book.
In C++ create a database of books that are stored using a vector. Keep track of the author, title, and publication date of each book. Your program should have a main menu that allows the user to select from the following: (1) Add a books author, title, and date; (2) Print an alphabetical list of the books sorted by author; and (3) Quit.
Must use a class to hold the data for each book. This class must hold three string fields: one to hold the authors name, one for the publication date, and another to hold the books title. Store the entire database of books in a vector in which each vector element is a book class object.
To sort the data, use the generic sort function from the library. Note that this requires you to define the < operator to compare two objects of type Book so that the author field from the two books are compared. A sample of the input/output behavior might look as follows. Your I/O need not look identical, this is just to give an idea of the functionality. Comment the code and your functions.
Select from the following choices:
1. Add new book
2. Print listing sorted by author
3. Quit
1
Enter title:
More Than Human
Enter author:
Sturgeon, Theodore
Enter date:
1953
Select from the following choices:
1. Add new book
2. Print listing sorted by author
3. Quit
1
Enter title:
Problem Solver
Enter author:
Savit, Walt
Enter date:
2015
Select from the following choices:
1. Add new book
2. Print listing sorted by author
3. Quit
2
The books entered so far, sorted alphabetically by author are:
Savit, Walt. Problem Solver. 2015.
Sturgeon, Theodore. More Than Human. 1953.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started