Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a program that displays movie ratings in a bar chart, similar to the one

ID: 3591698 • Letter: C

Question

Create a program that displays movie ratings in a bar chart, similar to the one shown in Figure 8-28. If necessary, create a new project named Advanced21 Project, and save it in the Cpp8Chap08 folder. Enter your C++ instructions into a source file named Advanced21.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Save and then run the program. Test the program appropriately.

How many reviewers? 4 Movie ratings must be from 1 to 5. Reviever 1 rating: 7 The rating nust be from 1 to 5 Reviever 1 rating: i Reviever 2 rating: 4 Reviever 3 rating: Reviever 4 rating: 3 Press any key to continue . Figure 8-28

Explanation / Answer

#include <iostream>

using namespace std;

int main() {

cout << "How many reviewers? ";

int reviewers;

cin >> reviewers;

cout << "Movie ratngs most be from 1 to 5." << endl << endl;

for(int i = 1; i <= reviewers; i++) {

int rating;

while(true) {

cout << "Reviewer " << i << " rating: ";

cin >> rating;

if (rating >= 1 && rating <= 5) {

break;

}

else {

cout << "The rating must be from 1 to 5" << endl;

}

}   

for (int j = 0; j < rating; j++) {

cout << "*";

}

cout << endl;

}

return 0;

}

Sample run

How many reviewers? 4
Movie ratngs most 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: 3
***
Reviewer 4 rating: 5
*****

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote