Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MovieRatingsTest.java public class MovieRatingsTest { public static void main(String args[]) { String[] movies = {Gravity, 12 Years a Slave, Spaceballs}; String[] reviewers = {Jen, Bino,

image text in transcribed

image text in transcribed

image text in transcribed

MovieRatingsTest.java

public class MovieRatingsTest { public static void main(String args[]) { String[] movies = {"Gravity", "12 Years a Slave", "Spaceballs"}; String[] reviewers = {"Jen", "Bino", "Sophia"}; MovieRatings ratings = new MovieRatings(reviewers, movies); //give some values for the ratings for(int i = 0; i for(int j=0; j ratings.setRating(i, j, i+j); ratings.printReviewerRatings(0); //prints 0, 1, 2 for Gravity ratings.printReviewerRatings(1); //prints 1, 2, 3 for 12 Years a Slave ratings.printReviewerRatings(2); //prints 2, 3, 4 for Spaceballs ratings.printMovieRatings(0); //prints 0, 1, 2 for Jen ratings.printMovieRatings(1); //prints 1, 2, 3 for Bino ratings.printMovieRatings(2); //prints 2, 3, 4, for Sophia System.out.println("Index for 12 Years a Slave: " + ratings.getMovieIndex("12 Years a Slave")); //prints 1 System.out.println("Index for Bino: " + ratings.getReviewerIndex("Bino")); //prints 1 System.out.println("Average Rating: " + ratings.getAvgRating()); //prints System.out.println("Average Rating by Jen: " + ratings.getAvgRatingsByReviewer(0)); //prints 1.0 System.out.println("Average Rating for Spaceballs: " + ratings.getAvgRatingsByMovie(2)); //prints 3.0 } }

Create a program to store and process movie ratings. Use a 2D array to store ratings by different reviewers for different movies. Each row represents a different movie and each column represents a different reviewer. There will also be two separate arrays to store the names of movies and the names of the reviewers. You may use the atached t test program MovieRatings ratingsI:int reviewersll String movies]: String +MovieRatings(reviewersI: String, moviesl String) getAvgRating:double +getAvgRatingbyMovie movielndex:int): double + getAvgRatingbyReviewer(reviewerlndex:int):double + getMovielndex(movieName: String):int +getReviewerlndex(reviewerName:String):int +setRating(movielndex:int, reviewerlndex:int, rating:int):void + printMovieRatingsmovielndex:int):void + printReviewerRatings reviewerlndex:int):void MovieRatings() - Constructor for the class One parameter is an array of reviewers names One parameter is an array of movie names Description: set the parameters equal to the private data members for the movies and reviewers, initialize the 2D ratings array based on the size of the reviewers array (rows) and the size of the movies array (columns) . getAvgRating0 Returns a double value representing the average rating Description: Find the average rating for all movies and all reviewers (ie all data in the table) getAvgRatingsbyMovie) One parameter, the index of the movie to find all the reviews for - Returns a double value representing the average rating Description: Find the average rating for a single movie (i e. one column representing all the reviewers scores for that one movie) getAvgRatingsbyReviewer) One parameter, the index of the reviewer to find all the reviews for Returns a double value representing the average rating Description: Find the average rating for a single reviewer (Le-one row representing all the movies for that one reviewer)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions