Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++, create a function calcAvgRating that returns the average (mean) rating for a particular book. This function should: Accept five arguments in this order: string:

C++, create a function calcAvgRating that returns the average (mean) rating for a particular book. This function should: Accept five arguments in this order: string: book title for which you want the average rating string array: titles 2D int array: list of ratings for each user (same comment here) int: number of users in the arrays int: number of books accounted for in the 2D array Return the average rating of the specified book as a double If the program has not read ratings.txt or books.txt, it must read it first before executing this function. In this case, return -1 after printing the following message: cout << bookTitle << " does not exist in the database" << endl; If instead the database is initialized but the book is not found, return -1 after printing the following message: cout << bookTitle << " does not exist in the database" << endl; Highly recommend: Write a helper function that searches the titles array for a particular book and returns its index. Note: If the user has not reviewed the book it should not be added while calculating the average.

Sample lines from books.txt:

Douglas Adams,The Hitchhiker's Guide To The Galaxy

Richard Adams,Watership Down

Mitch Albom,The Five People You Meet in Heaven

(etc.)

Sample lines from ratings.txt:

cynthia,4 3 1 0 3 0 5 1 5 2 2 2 1 4 4 2 0 1 1 2 3 2 1 1 3 4 1 2

1 3 0 0 3 1 1 3 2 3 1 2 3 4 5 5 0 1 3 2 2 4

diane,3 1 1 0 2 2 3 1 0 1 4 3 1 2 1 1 5 2 4 0 3 2 1 5 4 5 0 2 3

3 5 2 2 1 4 5 2 4 5 2 3 3 5 5 4 1 3 4 2 3

(etc.)

The format is ,

The order of ratings, rating_0, rating_1, rating_2,... correspond to the order of books in the books.txt file

Rating Meaning

0 Did not read

1 Hell No - hate it!!

2 Dont like it.

3 Meh - neither hot nor cold

4 Liked it!

5 Mind Blown - Loved it!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

Define and discuss the process of planned change.

Answered: 1 week ago