Question: Hello! I need some help fixing my c++ code , so that the highest rated movie for the entered move reviewer is displayed. For example,
Hello! I need some help fixing my c++ code, so that the highest rated movie for the entered move reviewer is displayed. For example, if the user enter 4, the highest rated movie for reviewer number 4 should be displayed. Here is what the output should look like (2nd photo). Everything in my code is working fine except for the showReviewersHighestRating function.


#include
#include
#include
#include
using namespace std;
const int NUM_REVIEWERS=4, NUM_MOVIES=6; //Rows and Columns
//Function Prototypes
void displayRatings(int [][NUM_MOVIES]);
void showAverageRatings(int [][NUM_MOVIES]);
void showReviewersHighestRating(int [][NUM_MOVIES]);
int main()
{
int ratings[NUM_REVIEWERS][NUM_MOVIES] = {{3, 1, 5, 2, 1, 5}, {4, 2, 1, 4, 2, 4}, {3, 1, 2, 4, 4, 1}, {5, 1, 4, 2, 4, 2}};
int choice;
do
{
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cin >> choice;
cout
//Menu choices
switch (choice)
{
case 1: displayRatings(ratings);
break;
case 2: showAverageRatings(ratings);
break;
case 3: showReviewersHighestRating(ratings);
break;
case 4: return 2;
break;
default: cout
}
} while (choice != 4);
//Function Calls
displayRatings(ratings);
showAverageRatings(ratings);
showReviewersHighestRating(ratings);
return 0;
}
void displayRatings(int ratings [][NUM_MOVIES])
{
cout
cout
cout
for(int r = 0; r
{
cout
for (int c = 0; c
cout
cout
}
}
void showAverageRatings(int ratings [][NUM_MOVIES])
{
int r, c;
float average = 0;
float sum = 0;
int movie_number = 101;
cout
for (c = 0; c
{
sum = 0;
for (r = 0; r
{
sum += ratings[r][c];
}
average = sum / NUM_REVIEWERS;
cout
}
}
void showReviewersHighestRating(int ratings [][NUM_MOVIES]) //Needs to be fixed
{
double lowest, reviewerNumber;
lowest = ratings[0][0]; //get the first array's first element
//Step through rest of array. When a value less than lowest is found, assign it to lowest.
for (int c = 0; c
{
for (int r = 0; r
{
if (ratings[NUM_MOVIES][NUM_REVIEWERS]
lowest = ratings[NUM_MOVIES][NUM_REVIEWERS];
}
do
{
cout
cin >> reviewerNumber;
} while (reviewerNumber 4);
if(reviewerNumber 4)
{
cout
cout
cin >> reviewerNumber;
}
}
}
2-D ARRAY PROCESSING MENU OPTIONS 1. Display current movie ratings 2. Show the average rating for each movie. 3. Show a reviewers highest rated movie. (enter reviewer# 1-4) 4. Show a movies lowest rating. (enter movie# 100-105) Enter new ratings (1-5) for movie# 100-105 for four reviewers 6. Quit program Enter your choice:1 REVIEWER! MV4100 MV4101 MV4102 MV4103 MV4104 MV4105 #1 #2 #3 4 4 4 2-D ARRAY PROCESSING MENU OPTIONS 1. Display current movie ratings 2. Show the average rating for each movie. 3. Show a reviewers highest rated movie. (enter reviewer# 1-4) 4. Show a movies lowest rating. (enter movie# 100-105) Enter new ratings (1-5) for movie# 100-105 for four reviewers 6. Quit program Enter your choice:2 MOVIE RATINGS REVIEWER! MV4100 MV4101 MV4102 m/#103 MV4104 MV4105 #1 #2 #3 #4 4 4 4 4 4 Average Rating for Movie#100: 3 . 75 Movie#101: 1 . 25 Movie#102: 3 Movie#103: 3 Movie#104 : 275 Movie#105: 3 each movie
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
