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 10:00
Jackson is teaching the decimal number system. he wants his students to know how to expand numbers by powers of 10. which is the correct order in which digits are assigned values in the decimal number system?
Answers: 1
question
Computers and Technology, 24.06.2019 00:10
Read each statement below. if the statement describes a peer-to-peer network, put a p next to it. if the statement describes a server-based network, put an s next to it. p - peer-to-peer s - server-based
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
How would you cite different books by the same author on the works cited page? moore, jack h. folk songs and ballads. salem: poetry press, 1999. print. moore, jack h. ballads in poetry – a critical review. dallas: garden books, 1962. print. moore, jack h. folk songs and ballads. salem: poetry press, 1999. print. –––. ballads in poetry – a critical review. dallas: garden books, 1962. print. moore, jack h. ballads in poetry – a critical review. dallas: garden books, 1962. print. moore, jack h. folk songs and ballads. salem: poetry press, 1999. print. moore, jack h. ballads in poetry – a critical review. dallas: garden books, 1962. print. –––. folk songs and ballads. salem: poetry press, 1999. print.
Answers: 2
question
Computers and Technology, 24.06.2019 10:20
Multiple choice project create a program with two multiple choice questions. 1. users have two attempts only, show attempt number each time. hint: while loop with break control. (20%) 2. only one correct answer for each question, use switch case for each question. (20%) 3. show total score after the two questions are answered. hint: . (20%) 4. user have options to answer the two questions again if first attempt score is not 100%. hint: if statment. (20%) 5. use string method .toupper() to allow users to enter with lowercase or uppercase letters. (20%) 1. where is the capital of the state of florida? a. orlando b. tallahassee c. miami d. tampa b 2. where is walt disney world park located in florida? a. orlando b. tallahassee c. miami d. tampa a
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
English, 27.04.2021 01:50
question
Mathematics, 27.04.2021 01:50
Questions on the website: 13722363