subject

We will now update the readratings from homework 5 to use an array of user objects instead of having a usernames array and a ratings array. the functionality stays the same as the one from homework 5. write a function readratings that loads the user ratings by reading the ratings. txt file. the first value of each line in ratings. txt is the username. each username is followed by a list of ratings of the user for each book in books. txt. for example, let us say there are in total of 3 books. the ratings. txt file would be of the format: ritchie,3,3,3 stroustrup,0,4,5 gosling,2,2,3 rossum,5,5,5 this function should: accept five parameters in this order: â—‹ string filename: the name of the file to be read â—‹ array users: array of user objects â—‹ int numusersstored number of users currently stored in the arrays â—‹ int usersarrsize: capacity of the users arrays. the default value for this data member is 100. â—‹ int maxcol: maximum number of columns. the default value for this data member is 50. use ifstream and getline to read data from the file, making an instance of a user object for each line, and placing it in the users array. hint: you can use the split() - function from homework 4, with comma (",") as the delimiter. when you copy your code in the answer box on moodle coderunner, make sure you copy users class, readbooks() function, and split() function. you can use stoi to convert each rating value (a string, as read from the text file) into an integer value. empty lines should not be added to the arrays. the function should return the following values depending on cases: â—‹ case1: when numusersstored is greater than or equal to the usersarrsize, return -2. â—‹ case2: if the file cannot be opened, return -1. â—‹ case3: when numusersstored is smaller than the size of users array, keep the existing elements in users array, then read data from file and add (append) the data to the arrays. the number of users stored in the arrays cannot exceed the size of the users array. â—‹ case4: return the total number of users in the system, as an integer. â—‹ your function must check these cases in the order specified above. example 1: the users array is empty, so numusersstored is 0. ratings. txt ninja,0,1,2,3,4 myth,2,2,4,5,1 sphyer,3,1,0,0,5 daequan,0,0,0,0,2 function call user users[10]; int numusers = 0; int usersarrsize = 10; readratings("ratings. txt", users, numusersstored, usersarrsize, 50); return value 4 testing the data member username // code to print the values cout

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:30
What do character formats do for your document's message? a.set the tone b.provide organization c.provide clarity d.set how texts align with documents
Answers: 2
question
Computers and Technology, 24.06.2019 00:30
Asecurity policy is a a. set of guidlines b. set of transmission protocols c. written document d. set of rules based on standards and guidelines
Answers: 2
question
Computers and Technology, 24.06.2019 04:30
The ieee 802.11: defines standards for wireless local area network (wlan) communication protocols. identifies various computers or devices connected to a network. verifies any resource attached to another computer on a network that is different from the computer to which the user is logged on. connects multiple local area networks (lans) and wide area networks (wans).
Answers: 2
question
Computers and Technology, 24.06.2019 12:00
How can we take picture in this app
Answers: 1
You know the right answer?
We will now update the readratings from homework 5 to use an array of user objects instead of having...
Questions
question
Mathematics, 20.09.2021 08:00
question
Geography, 20.09.2021 08:00
question
Social Studies, 20.09.2021 08:00
question
English, 20.09.2021 08:00