Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include using namespace std; const int MAX _ RATINGS = 1 0 0 0 ; const int MAX _ CATEGORIES = 3 ; const
#include #include using namespace std; const int MAXRATINGS ; const int MAXCATEGORIES ; const int MAXAGEGROUPS ; struct Rating int category; int ageGroup; int value; ; Rating ratingsMAXRATINGS; int numRatings ; string categoriesMAXCATEGORIESHorror "SciFi "Drama"; string ageGroupsMAXAGEGROUPSBelow and above"; void displayMenu cout TV Show Rating Application" endl; cout Rate a TV show category" endl; cout Remove a rating" endl; cout Display ordered lists of ratings" endl; cout Display average ratings" endl; cout Search for ratings" endl; cout Top recent ratings" endl; cout Categories and age groups with most ratings" endl; cout Exit" endl; cout "Enter your choice: ; void rateCategory int categoryChoice, ageGroupChoice, rating; cout "Choose a category:" endl; for int i ; i MAXCATEGORIES; i cout i categoriesi endl; cout "Enter your choice: ; cin categoryChoice; if categoryChoice categoryChoice MAXCATEGORIES cout "Invalid category choice!" endl; return; cout "Choose an age group:" endl; for int i ; i MAXAGEGROUPS; i cout i ageGroupsi endl; cout "Enter your choice: ; cin ageGroupChoice; if ageGroupChoice ageGroupChoice MAXAGEGROUPS cout "Invalid age group choice!" endl; return; cout "Enter a rating : ; cin rating; if rating rating cout "Invalid rating value!" endl; return; if numRatings MAXRATINGS ratingsnumRatingscategory categoryChoice; ratingsnumRatingsageGroup ageGroupChoice; ratingsnumRatingsvalue rating; numRatings; cout "Rating added successfully!" endl; else cout "Maximum number of ratings reached!" endl; void removeRating int categoryChoice, ageGroupChoice, ratingToRemove; cout Remove Rating endl; Specify TV show Category cout Specify TV show Category endl; for int i ; i MAXCATEGORIES; i cout Press i for categoriesi endl; cout "Enter a choice: ; cin categoryChoice; if categoryChoice categoryChoice MAXCATEGORIES cout "Invalid category choice!" endl; return; Specify the age category cout Specify the age category endl; for int i ; i MAXAGEGROUPS; i cout Press i for age group of ageGroupsi endl; cout "Enter your choice: ; cin ageGroupChoice; if ageGroupChoice ageGroupChoice MAXAGEGROUPS cout "Invalid age group choice!" endl; return; Enter the rating value to be removed cout "Enter the rating value to be removed: ; cin ratingToRemove; bool removed false; for int i ; i numRatings; i if ratingsicategory categoryChoice && ratingsiageGroup ageGroupChoice && ratingsivalue ratingToRemove ratingsivalue ; Mark as removed with a value of removed true; cout "Rating value has been removed successfully!" endl; if removed cout "Rating not found!" endl; if removed cout "Rating not found!" endl; void displayOrderedLists Sort the ratings in ascending order for int i ; i numRatings ; i for int j ; j numRatings i ; j if ratingsjvalue ratingsj value swapratingsj ratingsj ; cout "Ascending order of ratings:" endl; for int i ; i numRatings; i if ratingsivalue cout "Category: categoriesratingsicategory Age Group: ageGroupsratingsiageGroup Rating: ratingsivalue endl; cout "Descending order of ratings:" endl; for int i numRatings ; i ; i if ratingsivalue cout "Category: categoriesratingsicategory Age Group: ageGroupsratingsiageGroup Rating:
#include
#include
using namespace std;
const int MAXRATINGS ;
const int MAXCATEGORIES ;
const int MAXAGEGROUPS ;
struct Rating
int category;
int ageGroup;
int value;
;
Rating ratingsMAXRATINGS;
int numRatings ;
string categoriesMAXCATEGORIESHorror "SciFi "Drama";
string ageGroupsMAXAGEGROUPSBelow and above";
void displayMenu
cout
TV Show Rating Application" endl;
cout Rate a TV show category" endl;
cout Remove a rating" endl;
cout Display ordered lists of ratings" endl;
cout Display average ratings" endl;
cout Search for ratings" endl;
cout Top recent ratings" endl;
cout Categories and age groups with most ratings" endl;
cout Exit" endl;
cout "Enter your choice: ;
void rateCategory
int categoryChoice, ageGroupChoice, rating;
cout "Choose a category:" endl;
for int i ; i MAXCATEGORIES; i
cout i categoriesi endl;
cout "Enter your choice: ;
cin categoryChoice;
if categoryChoice categoryChoice MAXCATEGORIES
cout "Invalid category choice!" endl;
return;
cout "Choose an age group:" endl;
for int i ; i MAXAGEGROUPS; i
cout i ageGroupsi endl;
cout "Enter your choice: ;
cin ageGroupChoice;
if ageGroupChoice ageGroupChoice MAXAGEGROUPS
cout "Invalid age group choice!" endl;
return;
cout "Enter a rating : ;
cin rating;
if rating rating
cout "Invalid rating value!" endl;
return;
if numRatings MAXRATINGS
ratingsnumRatingscategory categoryChoice;
ratingsnumRatingsageGroup ageGroupChoice;
ratingsnumRatingsvalue rating;
numRatings;
cout "Rating added successfully!" endl;
else
cout "Maximum number of ratings reached!" endl;
void removeRating
int categoryChoice, ageGroupChoice, ratingToRemove;
cout Remove Rating endl;
Specify TV show Category
cout Specify TV show Category endl;
for int i ; i MAXCATEGORIES; i
cout Press i for categoriesi endl;
cout "Enter a choice: ;
cin categoryChoice;
if categoryChoice categoryChoice MAXCATEGORIES
cout "Invalid category choice!" endl;
return;
Specify the age category
cout Specify the age category endl;
for int i ; i MAXAGEGROUPS; i
cout Press i for age group of ageGroupsi endl;
cout "Enter your choice: ;
cin ageGroupChoice;
if ageGroupChoice ageGroupChoice MAXAGEGROUPS
cout "Invalid age group choice!" endl;
return;
Enter the rating value to be removed
cout "Enter the rating value to be removed: ;
cin ratingToRemove;
bool removed false;
for int i ; i numRatings; i
if ratingsicategory categoryChoice && ratingsiageGroup ageGroupChoice &&
ratingsivalue ratingToRemove
ratingsivalue ; Mark as removed with a value of
removed true;
cout "Rating value has been removed successfully!" endl;
if removed
cout "Rating not found!" endl;
if removed
cout "Rating not found!" endl;
void displayOrderedLists
Sort the ratings in ascending order
for int i ; i numRatings ; i
for int j ; j numRatings i ; j
if ratingsjvalue ratingsj value
swapratingsj ratingsj ;
cout "Ascending order of ratings:" endl;
for int i ; i numRatings; i
if ratingsivalue
cout "Category: categoriesratingsicategory Age Group:
ageGroupsratingsiageGroup Rating: ratingsivalue endl;
cout "Descending order of ratings:" endl;
for int i numRatings ; i ; i
if ratingsivalue
cout "Category: categoriesratingsicategory Age Group:
ageGroupsratingsiageGroup Rating:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
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