Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

C++

image text in transcribed

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 program for MovieRatings does not use variables such as Acount, Bcount, classSize, etc. Please modify the program below to satisfy the conditions above.

// AverageGrade.h // Provides a C++ class definition that will collect the number of grades // in a classroom and determine the average grade for all students. // // This project implements a program similar to the MovieRatings project. It does not // provide all of the required 'information' shown on the movie ratings project definition. // It the movie ratings go from 1 to (bad to worse), but this program has grade from // A to F (best to worse). These differences need to be taken into account when using // this program as a reference to build the MovieRatings project. #ifndef AverageGrade_h // only compile this header file one time #define AverageGrade_h class AverageGrade { private: char className[100]; int Acount; int Bcount; int Ccount; int Dcount; int Fcount; int classSize; public: AverageGrade(); // default constructor AverageGrade(char *name); // constructor with one argument void countGrade (char grade); void setName(char *name); // mutator - sets the name into the object char *getName(); // accessor - gets the name from the object double getAverage(); }; #endif 

=======================================================================

// AverageGrade.cpp // // This project implements a program similar to the MovieRatings project. It does not // provide all of the required 'information' shown on the movie ratings project definition. // It the movie ratings go from 1 to (bad to worse), but this program has grade from // A to F (best to worse). These differences need to be taken into account when using // this program as a reference to build the MovieRatings project. #include "stdafx.h" // only used by some Microsoft C++ compilers #include "AverageGrade.h" #include  #include  #include  using namespace std; AverageGrade::AverageGrade() // default constructor { className[0] = '\0'; // set to an empty string Acount = Bcount = Ccount = Dcount = Fcount = 0; classSize = 0; } AverageGrade::AverageGrade(char *name) { // strcpy (className, name); // use if strcpy is required by the compiler strcpy_s (className, 100, name); // use if strcpy_s is required by the compiler Acount = Bcount = Ccount = Dcount = Fcount = 0; classSize = 0; } void AverageGrade::setName(char* name) // mutator - sets the className { // strcpy (className, name); // use if strcpy is required by the compiler strcpy_s (className, 100, name); // use if strcpy_s is required by the compiler } char* AverageGrade::getName() // accessor - gets the className { return className; } void AverageGrade::countGrade (char grade) { switch ( toupper(grade) ) { case 'A': Acount++; // count the number of A's classSize++; // count the number of students break; case 'B': Bcount++; // count the number of A's classSize++; // count the number of students break; case 'C': Ccount++; // count the number of A's classSize++; // count the number of students break; case 'D': Dcount++; // count the number of A's classSize++; // count the number of students break; case 'F': Fcount++; // count the number of A's classSize++; // count the number of students break; default: cout  

===================================================================

// C++MovieRatings.cpp : Defines the entry point for the console application. // // This project implements a program similar to the MovieRatings project. It does not // provide all of the required 'information' shown on the movie ratings project definition. // It the movie ratings go from 1 to (bad to worse), but this program has grade from // A to F (best to worse). These differences need to be taken into account when using // this program as a reference to build the MovieRatings project. #include "stdafx.h" // only used by some versions of Microsoft C++ #include "AverageGrade.h" #include  using namespace std; int main(int argc, char* argv[]) { AverageGrade CIS054; // create an object of class AverageGrade CIS054.setName("C/C++ Programming"); // use mutator to set the class name CIS054.countGrade('A'); CIS054.countGrade('B'); CIS054.countGrade('A'); CIS054.countGrade('C'); CIS054.countGrade('B'); CIS054.countGrade('A'); CIS054.countGrade('F'); cout  

11. 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) 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

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

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

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago