Question: You were given two text files with comma separated values: books.txt, which is a list of books and their authors, and ratings.txt, which is a

You were given two text files with comma separated values: books.txt, which is a list of books and their authors, and ratings.txt, which is a list of users and their ratings of those books. The first task is to read these files and load their contents into arrays for convenient processing.

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;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!