Question

C++, this is an intro class please do not make it complicated.

Consider a class Movie that contains information about a movie. The class has the following attributes The movie name The MPA

Sample Output for Problem 02 Movie 1(The Adjustment Bureau, PG-13) Ratings (5,5,4,4,5) Movie 2 (I Am Number Four, PG-1

Consider a class Movie that contains information about a movie. The class has the following attributes The movie name The MPAA rating (for example, G, PG, PG-13, R) An array to store the movie ratings .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 with accessor and mutator functions for the movie name and MPAA rating. Write a function addRating that takes an integer as an input parameter. The function should verify that the parameter is a number between 1 and 5, and if so, increment 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 as a 3 should be incremented by 1. Write another function, getAverage, that returns the average value for all of the movie ratings. Finally, add a constructor that allows the programmer to create the object with a specified name and MPAA rating. The number of people rating the movie should be set to 0 in the constructor. Test the class by writing a main function that creates at least two movie objects, adds at least five ratings for each movie, and outputs the movie name, MPAA rating, and average rating for each movie object.
Sample Output for Problem 02 Movie 1("The Adjustment Bureau", "PG-13") Ratings (5,5,4,4,5) Movie 2 ("I Am Number Four", "PG-13") Rating(3,2,2,4,1) The Adjustment Bureau,PG-13 Average rating: 4-6 I Am Number Four, PG-13 AVerage rating: 2 4 Press any key tocontinue- Problem 02 Grading Criteria: 10 points for addRating and getAverage fucntions. .5 points for the accessor functions .5 points for the mutators functions .5 points for testing all above functions in the main function .5 points will be deducted if you do not include two constructors and use them correctly.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
using namespace std;
class Movie
{
private:
string name;
int rating[5], rate;
int terrible = 0, bad = 0, ok = 0, good = 0, great = 0;
string MPAA;
double average = 0;
public:
Movie()
{ }
Movie(string Name, string mpaa)
{
name = "The Adjustment Bureau";
MPAA = "PG-13";
rate = 0;
for(int i = 0; i < 5; i++)
{
rating[i] = 0;
}
}
void setname(string nam)
{
name = nam;
}
string getname()
{
return name;
}
void setrating(string mpaa)
{
MPAA = mpaa;
}
string getrating()
{
return MPAA;
}
void addRating(int rate)
{
if(rate >= 1 && rate <= 5)
{
rating[rate - 1]++;
}
switch(rate)
{
case 1:
terrible++;
break;
case 2:
bad++;
break;
case 3:
ok++;
break;
case 4:
good++;
break;
case 5:
great++;
break;
}
}
double getAverage()
{
int total;
total = 0; rate = 0;
for(int i = 0; i < 5; i++)
{
rate = rate + rating[i];
total = total + rating[i] * (i + 1);
}
if(rate > 0)
{
return (total / rate);
}
else
return 0;
}
int display()
{
cout<<"\n Name: "<<getname();
cout<<"\n MPAA: " <<getrating();
cout<<"\n Average Rating: " <<getAverage();
cout<<"\n The people have rated tihs movie as 1 (Terrible): " <<terrible;
cout<<"\n The people have rated tihs movie as 2 (Bad): " <<bad;
cout<<"\n The people have rated tihs movie as 3 (Ok): " <<ok;
cout<<"\n The people have rated tihs movie as 4 (Good): " <<good;
cout<<"\n The people have rated tihs movie as 5 (Great): " <<great;
return 0;
}
};
int main()
{
Movie m, m1;
string name, rating;
m.setname("The Adjustment Bureau");
m.setrating("PG");
m.getAverage();
  
m.addRating(5);
m.addRating(5);
m.addRating(4);
m.addRating(5);
m.addRating(5);
m.display();
  
cout<<endl;
m1.addRating(3);
m1.addRating(2);
m1.addRating(2);
m1.addRating(4);
m1.addRating(1);
m1.setname("I Am Number Four ");
m1.setrating("PG-13");
m1.getAverage();
m1.display();
return 0;
}


Name: The Adjustment Bureau
MPAA: PG
Average Rating: 4
The people have rated tihs movie as 1 (Terrible): 0
The people have rated tihs movie as 2 (Bad): 0
The people have rated tihs movie as 3 (Ok): 0
The people have rated tihs movie as 4 (Good): 1
The people have rated tihs movie as 5 (Great): 4

Name: I Am Number Four
MPAA: PG-13
Average Rating: 0
The people have rated tihs movie as 1 (Terrible): 1
The people have rated tihs movie as 2 (Bad): 2
The people have rated tihs movie as 3 (Ok): 1
The people have rated tihs movie as 4 (Good): 1
The people have rated tihs movie as 5 (Great): 0

Add a comment
Know the answer?
Add Answer to:
Consider a class Movie that contains information about a movie. The class has the following attri...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ A sample project is provided AverageGrade that is very similar to the MovieRatings project, but...

    C++ A sample project is provided AverageGrade that is very similar to the MovieRatings project, but it only is inputting one string (className) instead of both the movie name and the MPAA rating. Another difference is that the AverageGrade program scores grades A to F with point values from 4.0 to 0.0 (highest to lowest) while the MovieRatings scores the rating from 1 to 5 (lowest to highest). When using the AverageGrade program as a reference, make sure that the...

  • *URGENT* Written in C csv file name is movies.csv trr Name: Date: Movie Structure File ite...

    *URGENT* Written in C csv file name is movies.csv trr Name: Date: Movie Structure File ite a program that will read in a CSV file with information regarding movies. The file will contain a movie name, MPAA coding (G, PG, PG-13, R), number of minutes, and ratings (1-10) from the three top critics. Your program will read in the data into an array of structures and send the array to a function that will professionally display all of the information,...

  • HELP WITH C++ The following movies have recently come out: 1. Black Panther, PG-13 2. Avengers:...

    HELP WITH C++ The following movies have recently come out: 1. Black Panther, PG-13 2. Avengers: Infinity War, PG-13 3. A Wrinkle In Time, PG 4. Ready Player One, PG-13 5. Red Sparrow, R 6. The Incredibles 2, G To do: 1. Create a Movie class that stores the movie name and the MPAA rating (i.e. R, PG13, etc.). Write appropriate constructors, setters, and getters. 2. In your main function create an array of type Movie that stores the movie...

  • BACKGROUND Movie Review sites collect reviews and will often provide some sort of average review to...

    BACKGROUND Movie Review sites collect reviews and will often provide some sort of average review to sort movies by their quality. In this assignment, you will collect a list of movies and then a list of reviews for each movie. You will then take a simple average (total of reviews divided by number of reviews) for each movie and output a sorted list of movies with their average review. Here you are provided the shell of a program and asked...

  • a movie has a name, an imdb rating. It has number of users who rated 2. It has number of users who rated 3. It has number of users who rated 4. It has number of users who rated 5.. Provide the accessors and mutators methods for movie name and imdb rating.

    a movie has a name, an imdb rating. It has number of users who rated 2. It has number of users who rated 3. It has number of users who rated 4. It has number of users who rated 5.. Provide the accessors and mutators methods for movie name and imdb rating. One can add rating with input asa a number ranging from 1-5. Depending on the rating increment the user count of that rating.The average rating can be calculated...

  • Java program. Mike's Movie Theater is a local cinema showing the latest Hollywood hits. Create a...

    Java program. Mike's Movie Theater is a local cinema showing the latest Hollywood hits. Create a class called Movie that stores basic information about a single movie: the title, the running time or length of the film (in minutes), the showtimes (as a single string, such as "11:00,3:15,7:30"), and the film's rating (R, PG-13, PG, or G). Include get and set methods for each; the setter for rating should check that the value is one of the four valid options...

  • C++ Programing In this exercise, you will design a class memberType. The class has the following...

    C++ Programing In this exercise, you will design a class memberType. The class has the following data members: memberName. A string that holds the name of a person memberID. A string that holds the member identification number numBooks. An int that holds the number of books bought purchaseAmt. A double that holds the amount spent on books In addition, the class should have the following constructor and other member functions. Constructor. The constructor should accept the person’s name and member...

  • Overload a relational operator for the Job class: Assume that this operator is not overloaded for...

    Overload a relational operator for the Job class: Assume that this operator is not overloaded for the Salary class. a) Write how the function will be declared in your code. b) Write an external function definition (not inside the class). solve it in C++10 to solve this you nedd question number 1. Create a composition between the classes Job and Salary. Class Salary a. data member:    1. money b. constructors:    1. default constructor    2. user defined constructor with a parameter...

  • COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see...

    COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see which professor has the highest rating according to student input. You will create a ProfessorRating class consisting of professor Name and three ratings. The three ratings are used to evaluate easiness, helpfulness, and clarity. The value for each rating is in the range of 1 to 5, with 1 being the lowest and 5 being the highest. Your program should contain the following functionalities:...

  • C++ Assignment: Create a class called FitnessMember that has only one variable, called name. The FitnessMember...

    C++ Assignment: Create a class called FitnessMember that has only one variable, called name. The FitnessMember class should have a constructor with no parameters, a constructor with a parameter, a mutator function and an accessor function. Also, include a function to display the name. Define a class called Athlete which is derived from FitnessMember. An Athlete record has the Athlete's name (defined in the FitnessMember class), ID number of type String and integer number of training days. Define a class...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT