Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function readRatings that performs a similar task on the user ratings file. Each username represented in ratings.txt is followed by list of integers--ratings

Write a function readRatings that performs a similar task on the user ratings file. Each username represented in ratings.txt is followed by list of integers--ratings of each book in books.txt.

Your function should:

Accept six arguments in this order:

string: the name of the file to be read

string array: usernames

2D int array: list of ratings for each user (first index specifies user)

int : number of users currently stored in the arrays

int: row capacity of the 2D array (convention: array[row][column]) [assume to be 100]

int: column capacity of the 2D array [assume to be 50]

Use ifstream, stringstream, and getline to read and parse data from the file, placing usernames in the usernames array and book ratings in the ratings array (stoi will also be useful here)

Print the username of each user as they are added to the system cout

Return the total number of users in the system, as an integer.

If the file cannot be opened, return -1

Hint: You can use the split() function that was used during recitation

image text in transcribedimage text in transcribed

Rating Meaning Did not read Hell No hate it!! Don't like it. Meh neither hot nor cold Liked it! Mind Blown-Loved it! Rating Meaning Did not read Hell No hate it!! Don't like it. Meh neither hot nor cold Liked it! 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

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

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

5. What information would the team members need?

Answered: 1 week ago

Question

Which team solution is more likely to be pursued and why?

Answered: 1 week ago