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 6 input arguments in the following order:
string: username
string: title of the book
Array of User objects: users
Array of Book objects: books
int: number of users currently stored in the users array
int: number of books currently stored the books array
The username and book 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:
Return the rating value if both user and title are found
Return -3 if the user or the title are not found
bool stringComp(const string &s1, const string &s2) {
if (s1.size() != s2.size()) return false;
for (string::const_iterator c1 = s1.begin(), c2 = s2.begin(); c1 != s1.end(); ++c1, ++c2) {
if (tolower(*c1) != tolower(*c2))
return false;
}
return true;
}
int getRating(const string& userName, const string& title, string users[], string titles[], int ratings[][50], int numUsers, int numBooks) {
int userIndex = -1;
for (int i = 0; i < numUsers; i++)
if (stringComp(userName, users[i]))
userIndex = i;
int titleIndex = -1;
for (int i = 0; i < numBooks; i++)
if (stringComp(title, titles[i]))
titleIndex = i;
if (userIndex == -1 || titleIndex == -1)
return -3;
return ratings[userIndex][titleIndex];
}
Write a function that, given a user’s name and a book’s title, returns the rating that...
C++ I only need a clear explanation on how to read the file,
then get the ratings from a txt file as integers by splitting by
comma. (The first item on each line is always the username.) Sum up
everything that is NOT 0 and divide by the total amount not
including 0 ratings.
No vectors
using namespace std
The member function getCountReadBooks which determines how many
books a particular user has read and reviewed. This function
should:
● Accept...
C++ Double Question : 1ST. The printAllBooks function from Homework 5 was very useful, let’s do it again, but with an array of Book this time! Write a new printAllBooksfunction which will be useful to display the contents of your library. This function should: Accept two parameters in this order: array books: array of Book objects. int: number of books in the array (Note: this value might be less than the capacity of 50 books) This function does not return...
Implement the classes in the following class diagram. The Book class implements the Comparable interface. Use implements Comparable<Book> in the class definition. Now, all book objects are instances of the java.lang.Comparable interface. Write a test program that creates an array of ten books. 1. Use Arrays.sort( Book[]l books) from the java.util package to sort the array. The order of objects in the array is determined using compareTo...) method. 2. Write a method that returns the most expensive book in the...
Write a class called Book. Here are the relevant attributes: title author yearPublished bookPriceInCAD Provide a constructor that takes parameters to initialize all the instance variables. The constructor calls the mutator (set) methods to initialize the instance variables. Provide an accessor (get) and mutator (set) for each instance variable. The mutators all validate their parameters appropriately and use them only if valid. If the passed parameter was invalid an IllegalArgumentException will be thrown with a proper error message A...
Don't attempt if you can't attempt fully, i will dislike and negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book titnle, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an HTML web...
please write this program in C++(Linux). Also write all the
explanation of codes, the comment for your code.
Description You are an avid reader and have decided that you would like to keep track of the books that you read. You will define a structure called book_list that will hold 1. a number associated with each book (int) 2. book title (string), 3. author (string), 4. a description of the book (string), 5. a date when the book was read...
Write a definition for a class named Book with attributes title, price and author, where author is a Contact object and title is a String, and price is a float number. You also need to define the Contact class, which has attributes name and email, where name and email are both String. Instantiate a couple of Book objects that represents books with title, price and author (You can come up with the attributes values for each object) Write a function...
IN C++ My project will be a library management system. It will have seven functions. It HAS to contain: classes, structures, pointers and inheritance. fix code according to below 1. Add a new book allows the user to enter in book name and book code Book code has to be in # “Invalid book code” “book name has been added to library” book code will be used to borrow books 2. Add a new user must use first user must...
using the source code at the bottom of this page, use the following instructions to make the appropriate modifications to the source code. Serendipity Booksellers Software Development Project— Part 7: A Problem-Solving Exercise For this chapter’s assignment, you are to add a series of arrays to the program. For the time being, these arrays will be used to hold the data in the inventory database. The functions that allow the user to add, change, and delete books in the store’s...
Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book tit le, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an...