SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
Standard Template Library
Exercise:
Programming Projects
Question:7 | ISBN:9780321531346 | Edition: 7

Question

In this project you are to 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 book’s author, title, and date, (2) Print an

alphabetical list of the books sorted by author, and (3) Quit.

You must use a class to hold the data for each book. This class must hold

three string fields, one to hold the author’s name, one for the publication

date, and another to hold the book’s 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 <algorithm>

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 you an idea of the functionality.

Select from the following choices:

1. Add new book

2. Print listing sorted by author

3. Quit

1

The books entered so far, sorted alphabetically by artist are:

Kauffman, At Home in the Universe, 1996

Savitch, Walter. Problem Solving with C++. 2006.

Sturgeon, Theodore. More Than Human. 1953.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.

Spread the 'tradition of sharing'.