The New York Times newspaper has published “best seller” lists since 1942. Book sales are tracked nationwide, leading to a list of those books which have recently sold the most copies. You will design, implement and test a C++ program which allows the user to search a subset of the books which have appeared in the New York Times best seller lists. For simplicity, the data set will only contain those books which have reached #1 on either of two lists (fiction and nonfiction) since 1942. The file included named bestsellers.txt contains the complete data set. Each line of the file contains the information for a separate book, which includes: title, author, publisher, date it first reached #1 on one of the best seller lists, and category (fiction or nonfiction). There is a tab character ('\t') between fields. Add a BestSellers class that contains a single attribute of a vector of Book objects, an addBook method that receives a Book object and adds it to the vector, and a display method that contains a for loop to display all the Book objects' data in the same format you used in Lab9Quiz. Your main function should do the following: Create a BestSellers object Read the file and for each line of data read do the following: Create a Book object using the data read Add the Book object to the vector of books objects in the BestSellers class by calling the addBook method on the BestSellers object. you created. After the entire file is read, the program will display a menu of options and allow the user to search for books which meet certain criteria. The menu options are: Display all books in a particular year: Prompt the user for a year, then display all books which reached the #1 spot in that year. Search for an author: Prompt the user for a string, then display all books whose author’s name exactly matches the string. File bestsellers.txt is screenshotted below
In C++.
The New York Times newspaper has published “best seller” lists since 1942. Book sales are tracked nationwide, leading to a list of those books which have recently sold the most copies.
You will design, implement and test a C++ program which allows the user to search a subset of the books which have appeared in the New York Times best seller lists. For simplicity, the data set will only contain those books which have reached #1 on either of two lists (fiction and nonfiction) since 1942.
The file included named bestsellers.txt contains the complete data set. Each line of the file contains the information for a separate book, which includes: title, author, publisher, date it first reached #1 on one of the best seller lists, and category (fiction or nonfiction). There is a tab character ('\t') between fields.
Add a BestSellers class that contains a single attribute of a
Your main function should do the following:
Create a BestSellers object
Read the file and for each line of data read do the following:
Create a Book object using the data read
Add the Book object to the vector of books objects in the BestSellers class by calling the addBook method on the BestSellers object. you created. After the entire file is read, the program will display a menu of options and allow the user to search for books which meet certain criteria. The menu options are:
-
Display all books in a particular year: Prompt the user for a year, then display all books which reached the #1 spot in that year.
-
Search for an author: Prompt the user for a string, then display all books whose author’s name exactly matches the string.
- File bestsellers.txt is screenshotted below



Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images









