Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider a class Movie that contains information about a movie. The class has the following attributes: - The movie name - The MIPAA rating -

image text in transcribed

image text in transcribed

Consider a class Movie that contains information about a movie. The class has the following attributes: - The movie name - The MIPAA rating - The number of people that have rated this movie as a 1 (Terrible) - The number of people that have rated this movie as a 2 (Bad) - The number of people that have rated this movie as a 3 (OK) - The number of people that have rated this movie as a 4 (Good) - The number of people that have rated this movie as a 5 (Great) Implement the class according to the following specifications: - Write a constructor that creates the class with movie name, and MIPAA rating. All the ratings should be set to their default values of 0 . - Write a method addRating(int, that takes an integer as an input parameter. The method should verify that the parameter is a rating between 1 and 5 , and if so, increment by 1 the number of people rating the movie that match the input parameter. For example, if 3 is the input parameter, then the number of people that rated the movie 3 should be incremented by 1 . If the rating is not between 1 and 5 (inclusive) it must be ignored. - Write another method getAverage () that returns the average value for all the ratings. Write a test client TestmovieRating.java to the test the class. The test client should prompt the user to: - Input the name of the movie. - Input the MIPAA rating of the movie. - Keep prompting the user to enter the rating for the movie, until the user enters - 1. Once the user enters 1, the client prints the name of the movie, the MIPAA rating, and the average rating. Input cmd: java MovieTestrating Output Enter the name of the movie: The Hunger Games Enter the MIPAA rating of the move: PG-13 Enter the rating of the movie ( 1 to 5,1 to exit): 10 Incorrect rating Enter the rating of the movie (1 to 5,1 to exit): 1 Enter the rating of the movie (1 to 5,1 to exit): 2 Enter the rating of the movie (1 to 5,1 to exit): 3 Enter the rating of the movie (1 to 5,1 to exit): 4 Enter the rating of the movie (1 to 5,1 to exit): 5 Enter the rating of the movie (1 to 5,1 to exit): 1 Name of the movie: The Hunger Games MIPAA Rating: MG13 Average Rating 3.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago