Generate a text-based histogram for a quiz given to a class of students. The quiz is graded on a scale from 0 to 5. Write a program that allows the user to enter grades for each student. As the grades are being entered, the program should count, using an array, the number of 0’s, the number of 1’s, then number of 2’s, the number of 3’s, the number of 4’s and the number of 5’s. The program should be capable of handling an arbitrary number of student grades.
You can do this by making an array of size 6, where each array element is initialized to zero. Whenever a zero is entered, increment array[0]. Whenever a one is entered, increment array[1], and so on, up to array[5].
Output the histogram count at the end. For example, if the input grades are 3, 0, 1, 3, 3, 5, 5, 4, 5, 4, then the program should output
1 grade(s) of 0
1 grade(s) of 1
0 grade(s) of 2
3 grade(s) of 3
2 grade(s) of 4
3 grade(s) of 5
I have no idea how to finish up this program. I have started it, but I do not know what else to put in it. I'm a noob when it comes to coding :/. Here's what I have so far:
using namespace std;
int main ()
{
int i;
string grades[6];
int zero,one,two,three,four,five;
for (i=0; i<6; i++)
{
cout<< "Enter students grades";
getline (cin, grades [i]);
}
#include <cstdlib>
#include <iostream>
usingnamespace std;
int main(int argc, char *argv[])
{
char cont;
int myinput;
int grades[6] = {0};
do{
cin>>myinput;
if(myinput <= 5) // makes sure its in range of the array
grades[myinput]++; // increments the value at grades 0 - 5
cout << "Enter another value? y or n";
cin >> cont;
}while(cont != 'n'); //continue till n is entered
for(int i=0; i < 6; i++) // out put the array
cout << grades[i] << " grade(s) of (" << i << ")" << endl;
}