Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

C++ We now have a list of usernames and a list of ratings. Now, we want to search for a particular users rating for a

C++

image text in transcribed

image text in transcribed

We now have a list of usernames and a list of ratings. Now, we want to search for a particular users rating for a particular book title. Write a function that, given a user's name and a book's title, returns the rating that the user gave for that book. Your function MUST be named getRating. Your function should take 7 input arguments in the following order: o string: username o string: title of the book Array of strings: users Array of strings: titles o 2-Dimensional int array: ratings - list of ratings for each user [assume it has 100 rows and 50 columns] o int: number of users whose names/ratings are currently stored in the string array/2D array respectively ntnmber of books whose titles/ratings are currently stored in the string array/2D array respectively The username and title search should be case insensitive. "Ben, "ben" and "BEN" are one and the same user. If both the user name and the book title are found in the arrays, then the function should return the user's rating value for that book title. The function should return the following values depending on cases: o Return the rating value if both user and title are found o Return-3 if the user or the title are not found Value of users string users(21-"User1""User2 Value of titles ring titles[3] (Title1", Title2", "Title3" Value of ratings int ratings[2][3] 14,2 10,5,3); Example 1: Both the userName and bookTitle exists, and the value of rating is non-zero Function call getRating("User1", "Title2", users, titles, ratings, 2, 3); Return value4 Example 2: The userName does not exist, it returns -3 Function call Return value getRating("User4", "Title1", users, titles, ratings, 2,3) -3 Example 3: The bookTitle does not exist, it returns -3 Function call Return value getRating("User1", "Title10", users, titles, ratings, 2, 3); -3 Example 4: The userName and the bookTitle do not exist getRating("User12", "Title10", users, titles, ratings, 2, 3); Return value -3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions