1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include <iostream>
#include <cstdlib>
using namespace std;
const int NUM_REVIEWERS = 4; //Number of rows in reviews array
const int NUM_MOVIES = 6; //Number of columns in reviews array
void displayRatings(int [][NUM_MOVIES]);
void getRatings(int [][NUM_MOVIES]);
int main()
{
// Variable declarations
int reviews[NUM_REVIEWERS][NUM_MOVIES]={0}; // Ratings for reviewers
int choice;
getRatings(reviews);
do
{
cout<<"---------------------------------------------------"<<endl;
cout<<"2-D ARRAY PROCESSING MENU OPTIONS"<<endl;
cout<<"---------------------------------------------------"<<endl;
cout<<"1. Display current movie ratings"<<endl;
cout<<"2. Show the average rating for each movie."<<endl;
cout<<"3. Show a reviewers highest rated movie. (enter reviewer# 1-4)"<<endl;
cout<<"4. Show a movies lowest rating. (enter movie# 100-105)"<<endl;
cout<<"5. Quit program"<<endl;
cout<<endl<<"Enter your choice:";
cin>>choice;
switch (choice)
{
case 1:
displayRatings(reviews);
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
}
}while(choice!=5);
return 0;
}
void getRatings(int reviews[][NUM_MOVIES])
{
reviews[NUM_REVIEWERS][NUM_MOVIES]={{3,1,5,2,1,5},{4,2,1,4,1,4},{3,1,2,4,4,1},{5,1,4,2,4,2}};
}
void displayRatings(int reviews[][NUM_MOVIES])
{
for(int rowCnt = 0; rowCnt < NUM_REVIEWERS; rowCnt++)
{
for(int colCnt = 0; colCnt < NUM_MOVIES; colCnt++)
{
cout<<reviews[rowCnt][colCnt]<<" ";
}
cout << endl;
}
}
|