Question: code in java BookData Define a class BookData that keeps track of information for a book and how it is rated by customers (real numbers

code in java  code in java BookData Define a class BookData that keeps track
of information for a book and how it is rated by customers
(real numbers between 0.0 and 5.0). The class has the following public

BookData Define a class BookData that keeps track of information for a book and how it is rated by customers (real numbers between 0.0 and 5.0). The class has the following public methods: BookData(title, author) -- constructs a BookData object with the given title and a uthor review (rating) records a review for the book with given rating getTitle) -- returns the title of the book getRating -- returns the average of all ratings (0.0 if none) getNumReviews -- returns the number of reviews the book has recieved toString() -- returns a String with title, author, average rating, and number of r eviews Below is an example for a book that has been reviewed four times: BookData book = new BookData("1984", "George Orwell"); book review (4.7); book review (5); book review (4.9); book review (4.9); After these calls, the call book.getRating would return 4.875 (the average of the ratings). The toString method should return a string of the form: , by , ( reviews) The rating should be truncated to a single digit after the decimal point. For example, given the previous calls, book.toString() would produce: "1984, by George Orwell, 4.8 (4 reviews)" i Tip: Casting a double to an int truncates the value ex: (int) (3.6) = 3. We can utilize this trick to truncate at any decimal point: ex: (int) (10.8. 3.777)/ 10.0 - 3.7 (int) (100.0 3.777) / 100.0 - 3.77 If a book has been reviewed just once, then toString should include the grammatically correct text " review" rather than "1 reviews". The BookData class should also implement the comparable interface. Books that have a higher average rating should be considered "less" than other books so that they appear at the beginning of a sorted list. You should use the complete value of the average rating rather than the truncated value displayed by toString Books that have the same average rating should be ordered by the number of reviews, with books that have been reviewed more often considered "less" than books that have been The BookData class should also implement the comparable interface. Books that have a higher average rating should be considered "less" than other books so that they appear at the beginning of a sorted list. You should use the complete Walue of the average rating rather than the truncated value displayed by toString, Books that have the same average rating should be ordered by the number of reviews, with books that have been reviewed more often considered "less than books that have been reviewed less frequently Books with the same average rating and number of reviews should be compared lexicographically by title (case sensitively)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!