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 17:30
The forerunner to cell phones, pdas, and smartphones was
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
Describir textbook icon_person mira los dibujos y describe lo que está pasando. usa los verbos de la lista.
Answers: 1
question
Computers and Technology, 23.06.2019 20:00
What software programs are used to to create professional publication? a.) graphics programs b.) word processors c.) page layout programs d.) spreadsheet programs
Answers: 2
question
Computers and Technology, 24.06.2019 23:30
True or false when a host gets an ip address from a dhcp server it is said to be configured manually
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, 12.12.2019 18:31
question
Mathematics, 12.12.2019 18:31
question
History, 12.12.2019 18:31
question
Engineering, 12.12.2019 18:31
Questions on the website: 13722367