Two-dimensional array operations: Movie Ratings program ** You have recently collected reviews from four movie reviewers where the reviewers are numbered 1-4. Each reviewer has
Two-dimensional array operations: Movie Ratings program**
You have recently collected reviews from four movie reviewers where the reviewers are numbered 1-4. Each reviewer has rated six movies where the movies are numbered 100-105. The ratings range from 1 (terrible) to 5 (excellent). Note: To store the sample data below in a 2D array the reviewer numbers must be mapped to 0-3 (row indexes) and the movie ID%u2019s must be mapped to 0-5 (column indexes). The movie rating does not include data for unrated movies and only includes values related to the rating range provided. A sample data set with movie review ratings are shown in the following table:100 | 101 | 102 | 103 | 104 | 105 | |
1 | 3 | 1 | 5 | 2 | 1 | 5 |
2 | 4 | 2 | 1 | 4 | 2 | 4 |
3 | 3 | 1 | 2 | 4 | 4 | 1 |
4 | 5 | 1 | 4 | 2 | 4 | 2 |
Based on this information your program should allow the user a menu of 6 options. The options are:
- Display current movie ratings.
- Show the average rating for each movie.
- Show a reviewers highest rated movie. (enter reviewer# 1-4)*
- Show a movies lowest rating. (enter movie# 100-105)
- Enter new ratings (1-5) for movie# 100-105 for four reviewers.
- Exit the program.
*If a reviewer has rated multiple movies with the same highest rating, display all the movie numbers with the same highest rating in your output (this maybe on a single line or on multiple lines and would depend on how you have written the procedure in the function that is called for option#3). Points will not be deducted if it does not match the sample output below, but I must see all the movie numbers listed if there are multiple movies with the same highest rating.
- The size or dimensions of the array should be declared as two global constants. You must first set-up, initialize or store the sample reviewer rating data (see table above) in a two dimensional array. This is to ensure that valid data exists in the 2-D array in case the user chooses options 1 - 4 before exiting the program.
- Each option in the menu must simply call a function. Each function must at minimum pass in a two dimensional array and the parameter type must contain a size declarator for the number of columns (see Gaddis text Chapter#8, page 549). Note: When a multidimensional array parameter is given in a function heading or function declaration, the size of the first dimension is not given, but the remaining dimension sizes must be given in square brackets. Since the first dimension size is not given, you usually need an additional parameter of type int that gives the size of this first dimension. The following are two examples of a function declarations or prototypes with a two-dimensional array parameter someArray,
void getRatings(int someArray [][100], int numRows); //the array is passed by reference to the function with read/write access
void showRatings(const int someArray [][100], int numRows); //the array is passed by reference to the function but with read only access - You may use the partial program framework provided below as an initial set-up guide to begin writing your own algorithms or you may start entirely with your own approach and implement the necessary interface to this programming project. The requirement is that I see well-documented seperate function procedures that are called when menu options 1-5 are selected and that the function algorithms process the 2-D array data correctly.
- The program run-time output shown below is based on compiling the program to test each menu option. Use this as a guide while you write and test your programs interface and calls to specific function procedures.
- Use meaningful identifiers and include function documentation (see syllabus) particularly in the function header and elsewhere in the function body where appropriate. Credit is provided only for those function procedures that correctly process the array data based on the option selected.
- Prior to submission make sure that you compile and test each option in your program to ensure that the output is similar to the sample program ouput shown below. There will be no redo on this project.
INPUT VALIDATION: Prevent out of bound array access. For example with menu option#3 limit the user input to reviewer#1-4 and similarly with menu option#4 limit the user input to movie# 100-105. With menu option#5 limit the data entry for ratings to 1-5.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//The partial program framework below is provided as an initial set-up guide to begin writing your own function procedures or algorithms to process array data. No further details regarding this partial framework will be provided. //On the other hand you may find it more rewarding if you design, develop and implement your own program structure and logic routines. //Either way, remember that the requirement is that I see well-documented seperate function procedures that are called when menu options 1-5 are selected and that the function algorithms process the 2-D array data correctly.#include #include using namespace std;const int NUM_REVIEWERS = 4; //Number of rows in reviews arrayconst int NUM_MOVIES = 6; //Number of columns in reviews array // Although there are more, I have listed below a few sample function prototypes you may choose to begin writing functon definitions for or create your ownvoid initialRatings(int [][NUM_MOVIES], int); //a function to be defined to set all data elements in the 2-D array to the sample data provided in table above void getNewRatings(int [][NUM_MOVIES], int); //a function to be defined to set new reviewer rating values in the 2-D arrayvoid displayRatings(const int [][NUM_MOVIES], int); //a function to be defined to display current values in the in the 2-D arrayvoid showAverageRatings(const int [][NUM_MOVIES], int); //a function to be defined that calculates the average for each column in the 2-D arrayvoid showReviewersHighestRating(const int [][NUM_MOVIES], int); //a function to be defined that finds the highest value for a row in the 2-D arrayint main(){ // Variable declarations int someArray[NUM_REVIEWERS][NUM_MOVIES]; // Ratings for reviewerschar choice; initialRatings(someArray, NUM_REVIEWERS ); //function call with actual argument passing in the array and the number of rows do { //program interface with menu options cout<<"---------------------------------------------------"< cout<<"2-D ARRAY PROCESSING MENU OPTIONS"< cout<<"---------------------------------------------------"< cout<<"1. Display current movie ratings"< cout<<"2. Show the average rating for each movie."< cout<<"3. Show a reviewers highest rated movie. (enter reviewer# 1-4)"< cout<<"4. Show a movies lowest rating. (enter movie# 100-105)"< cout<<"5. Enter new ratings (1-5) for movie# 100-105 for four reviewers"< cout<<"6. Quit program"< cout< cin>>choice; switch (choice) { //call to various functions in each case } }while(choice!=6); return 0;}//function definitions related to the above mentioned function prototypes should go below the main function - remember to include appropriate function documentation in the function header and elswhere in the function body.......---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------**Although not required, Windows system users may include the following syntax, system("CLS"); //This command is used to clear the screen between menu option displays but you must add the following directive #include.
Here is a sample run of the program that you may use as a guide in helping set-up the interface and also provides a few check figures...
---------------------------------------------------2-D ARRAY PROCESSING MENU OPTIONS---------------------------------------------------1. Display current movie ratings2. 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)5. Enter new ratings (1-5) for movie# 100-105 for four reviewers6. Quit programEnter your choice:1********************* MOVIE RATINGS ****************REVIEWER| MV#100 MV#101 MV#102 MV#103 MV#104 MV#105**************************************************** #1 3 1 5 2 1 5 #2 4 2 1 4 2 4 #3 3 1 2 4 4 1 #4 5 1 4 2 4 2---------------------------------------------------2-D ARRAY PROCESSING MENU OPTIONS---------------------------------------------------1. Display current movie ratings2. 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)5. Enter new ratings (1-5) for movie# 100-105 for four reviewers6. Quit programEnter your choice:2********************* MOVIE RATINGS ****************REVIEWER| MV#100 MV#101 MV#102 MV#103 MV#104 MV#105**************************************************** #1 3 1 5 2 1 5 #2 4 2 1 4 2 4 #3 3 1 2 4 4 1 #4 5 1 4 2 4 2****************************************************Average Rating for each movie:Movie#100: 3.75Movie#101: 1.25Movie#102: 3Movie#103: 3Movie#104: 2.75Movie#105: 3---------------------------------------------------2-D ARRAY PROCESSING MENU OPTIONS---------------------------------------------------1. Display current movie ratings2. 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)5. Enter new ratings (1-5) for movie# 100-105 for four reviewers6. Quit programEnter your choice:3********************* MOVIE RATINGS ****************REVIEWER| MV#100 MV#101 MV#102 MV#103 MV#104 MV#105**************************************************** #1 3 1 5 2 1 5 #2 4 2 1 4 2 4 #3 3 1 2 4 4 1 #4 5 1 4 2 4 2Enter a reviewer number (1-4), to find the Movie they rated the highest:6That is an invalid reviewer number.Enter a reviewer number (1-4), to find the Movie they rated the highest:1Reviewer#1 rated Movie#102 and 105 as the highest (*for display format please see my note above)---------------------------------------------------2-D ARRAY PROCESSING MENU OPTIONS---------------------------------------------------1. Display current movie ratings2. 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)5. Enter new ratings (1-5) for movie# 100-105 for four reviewers6. Quit programEnter your choice:4********************* MOVIE RATINGS ****************REVIEWER| MV#100 MV#101 MV#102 MV#103 MV#104 MV#105**************************************************** #1 3 1 5 2 1 5 #2 4 2 1 4 2 4 #3 3 1 2 4 4 1 #4 5 1 4 2 4 2Enter a movie number (100-105), to find the lowest rating:107That is an invalid movie number.Enter a movie number (100-105), to find the lowest rating:103Movie#103 lowest rating is 2.---------------------------------------------------2-D ARRAY PROCESSING MENU OPTIONS---------------------------------------------------1. Display current movie ratings2. 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)5. Enter new ratings (1-5) for movie# 100-105 for four reviewers6. Quit programEnter your choice:5********DATA ENTRY FOR NEW MOVIE RATINGS ***************************************************************REVIEWER# 1:****************************************************Enter rating (1-5) for movie#100: 1Enter rating (1-5) for movie#101: 2Enter rating (1-5) for movie#102: 3Enter rating (1-5) for movie#103: 4Enter rating (1-5) for movie#104: 5Enter rating (1-5) for movie#105: 6Invalid rating. It must be from 1-5.Enter rating (1-5) for movie#105: 1****************************************************REVIEWER# 2:****************************************************Enter rating (1-5) for movie#100: 5Enter rating (1-5) for movie#101: 4Enter rating (1-5) for movie#102: 3Enter rating (1-5) for movie#103: 2Enter rating (1-5) for movie#104: 1Enter rating (1-5) for movie#105: 5****************************************************REVIEWER# 3:****************************************************Enter rating (1-5) for movie#100: 2Enter rating (1-5) for movie#101: 3Enter rating (1-5) for movie#102: 4Enter rating (1-5) for movie#103: 5Enter rating (1-5) for movie#104: 1Enter rating (1-5) for movie#105: 2****************************************************REVIEWER# 4:****************************************************Enter rating (1-5) for movie#100: 3Enter rating (1-5) for movie#101: 4Enter rating (1-5) for movie#102: 5Enter rating (1-5) for movie#103: 1Enter rating (1-5) for movie#104: 2Enter rating (1-5) for movie#105: 3---------------------------------------------------2-D ARRAY PROCESSING MENU OPTIONS---------------------------------------------------1. Display current movie ratings2. 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)5. Enter new ratings (1-5) for movie# 100-105 for four reviewers6. Quit programEnter your choice:1********************* MOVIE RATINGS ****************REVIEWER| MV#100 MV#101 MV#102 MV#103 MV#104 MV#105**************************************************** #1 1 2 3 4 5 1 #2 5 4 3 2 1 5 #3 2 3 4 5 1 2 #4 3 4 5 1 2 3---------------------------------------------------2-D ARRAY PROCESSING MENU OPTIONS---------------------------------------------------1. Display current movie ratings2. 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)5. Enter new ratings (1-5) for movie# 100-105 for four reviewers6. Quit programEnter your choice:8INVALID CHOICE ...please retype---------------------------------------------------2-D ARRAY PROCESSING MENU OPTIONS---------------------------------------------------1. Display current movie ratings2. 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)5. Enter new ratings (1-5) for movie# 100-105 for four reviewers6. Quit programEnter your choice:6Array processing test now concluded. Exiting program .....Process returned 0 (0x0) execution time : 408.257 sPress any key to continue.
If your program does not compile, it will not be graded. HINT: I am thinking six to seven two dimensional array processing functions with procedures or algorithms that address the menu choice should be adequate. When working with the array processing in your functions watch for "Off-By-One Errors".
Use a do while loop with a switch statement as shown above. You should call the relevant functions from each case. Compile your code often. Only write a small portion of code, let's say a single function for a specific menu option, check that it still compiles before moving on. This way when you get a syntax error, you can be fairly certain the error is in the part you just wrote.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started