Question: This program is supposed to accept scores and should store the count of each in an array. The scores must be in the range (0,4).
This program is supposed to accept scores and should store the count of each in an array. The scores must be in the range (0,4). and the program should terminate when 99 is entered. Upon exit it should prints out the distribution of scores with stars. A sample input and output is as follows.
Enter 99 to terminate. Please enter a score in the range (0,4): 0 Please enter a score: 0 Please enter a score: 0 Please enter a score: 1 Please enter a score: 2 Please enter a score: 2 Please enter a score: 3 Please enter a score: 3 Please enter a score: 3 Please enter a score: 3 Please enter a score: 99 Score Distribution 0*** 1* 2** 3**** 4
//M06-01 Debugging The Program for Displaying the Distribution #include
int main(void){ const int NUM_ELEMENTS = 5; int counts[NUM_ELEMENTS] = {0}; int score; cout << "Enter 99 to terminate. "; //get inital score from user cout << "Please enter a score in the range (0,4): "; cin >> score; while(score != 99){ counts[score]++; cout << "Please enter a score: "; cin >> score; } //prints the distribution cout << " Score Distribution "; for(int i=0; i }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
