### bar graph

Create a program that displays movie ratings on a bar chart, similar to the one shown in figure 8-28

Figure 8-28:

How many reviewers? 4
Movie ratings must be from 1 to 5.

Reviewer 1 rating: 7
The rating must be from 1 to 5.

Reviewer 1 rating: 5 *****
Reviewer 2 rating: 4 ****
Reviewer 3 rating: 5 *****
Reviewer 4 rating: 3 ***

Press any key to continue. . .

(I have gotten this far and it won't display more than one reviewer or the correct stars. please help. c++ instructions below.)

#include <iostream>
using namespace std;

int main()
{
int amntReviewers = 0;
int ratings = 0;
int astricks = 0;
{
cout << "Enter number of reviewers: ";
cin >> amntReviewers;
}
cout << "Movie ratings must be from 1 to 5.";

for (int amntReviewers = 1; amntReviewers <= 5; amntReviewers +=1);
{
cout << "Enter Ratings: " << "Movie ratings must be from 1-5.";
cin >> ratings;
for (int ratings = 1; ratings <= 6; ratings += 1)
cout << '*';
//end for
cout << endl;
} //end for
return 0;
It would be nice if you could use code tags.

This line
`for (int ratings = 1; ratings <= 6; ratings += 1)`
should be
`for (int i = 1; i <= ratings; i += 1)`

You then need another loop for each number of reviewers.
Okay, thank you! I have modified my program to reflect the following. I am not sure what I need to do to get it to start at "Enter ratings for reviewer 1" again after you enter 7 as a rating. Since 7 exceeds the rating limit it should allow you to enter the ratings for such reviewer once more. Please help.

#include <iostream>
using namespace std;

int main()
{
int reviewers = 0;
int ratings = 0;

cout << "Enter numbers of reviewers: " << endl;
cin >> reviewers;
cout << "Movie ratings must be between 1 and 5." << endl;

for (int reviewers = 1; reviewers <= 5; reviewers ++)
{
cout << "Enter ratings for reviewer " << reviewers << ":";
cin >> ratings;
if (ratings > 5)
{
cout << "The rating must be between 1 and 5!";
cin >> ratings;
}
for (int i = 0; i <= ratings; i += 1)
{
cout << "*";
}
cout << endl;
} // endlfor
system("PAUSE");

return 0;
}
 ``123456789101112131415161718192021222324252627282930`` ``````#include int main() { // note: this program assumes that the user enters only integers as input int num_reviewers = 0; std::cout << "Enter number of reviewers: " ; std::cin >> num_reviewers; const int MIN_RATING = 1 ; const int MAX_RATING = 5 ; for( int reviewer = 1; reviewer <= num_reviewers ; ++reviewer ) { std::cout << "Enter rating for reviewer " << reviewer << " [" << MIN_RATING << '-' << MAX_RATING << "]: "; int rating ; while( std::cin >> rating && ( rating < MIN_RATING || rating > MAX_RATING ) ) { std::cout << "The rating must be between " << MIN_RATING << " and " << MAX_RATING << "! rating? " ; } std::cout << "\nReviewer " << reviewer << " rating: " ; for( int i = 0 ; i < rating ; ++i ) std::cout << '*' ; std::cout << "\n\n" ; } // endlfor }``````
thank you.