Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 18, Problem 6PP

Solution to Programming Project 18.6

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

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 Solving with C++

Enter author:

Savitch, Walter

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:

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

Sturgeon, Theodore. More Than Human. 1953.

Select from the following choices:

1. Add new book

2. Print listing sorted by author

3. Quit

1

Enter title:

At Home in the Universe

Enter author:

Kauffman

Enter date:

1996

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 artist are:

Kauffman, At Home in the Universe, 1996

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

Sturgeon, Theodore. More Than Human. 1953.

Blurred answer
Students have asked these similar questions
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: Add a book’s author, title, and date Print an alphabetical list of the books sorted by author 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 where 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.   Note: you are required to create three files, Book.h, Book.cpp and TestProgram.cpp. Book.h   #ifndef BOOK_H #define BOOK_H   #include <string>…
Need help making a java file that combines both linearSearch and binarySearch •Both search methods must use the Comparable<T> interface and the compareTo() method.•Your program must be able to handle different data types, i.e., use generics.•For binarySearch, if you decide to use a midpoint computation formula that is different fromthe textbook, explain that formula briefly as a comment within your code. //code from textbook //linearSearch public static <T>    boolean linearSearch(T[] data, int min, int max, T target) {        int index = min;        boolean found = false;        while (!found && index <= max) {            found = data [index].equals(target);            index++;        }        return found;    } //binarySearch     public static <T extends Comparable<T>>    boolean binarySearch(T[] data, int min, int max, T target) {        boolean found = false;        int midpoint = (min + max)/2;        if (data[midpoint].compareTo(target)==0)…
write a python code named get_total_cases() takes the a 2D-list (similar to database) and an integer x from this  set {0, 1, 2} as input parameters. Here, 0 represents Case_Reported_Date, 1 represents Age_Group and 2 represents Client_Gender (these are the fields on the header row, the integer value represents the index of each of these fields on that row). This function computes the total number of reported cases for each instance of x in the text file, and it stores this information in a dictionary in this form {an_instance_of_x : total_case}. Finally, it returns the dictionary and the total number of all reported cases saved in this dictionary. (Suppose we want to know the total number of cases reported on each date, so use x = 0.) >>> result, total_cases = get_total_cases(database, 0) >>> display_dict(result) 2021-05-19: 8 2021-05-20: 2 2021-05-21: 1 2021-05-22: 1 >>> print(total_cases)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License