Hi I need guidance for this program and it seems i don't understand basic fundamentals of creating histogram with c++. I'm not asking for spoonfeeding or anything i just need to know what i'm doing wrong and is there anything i can include or to improve it.
This programe needs to print out a histogram about students and their marks, this program should allow a user to key in a total of 20 marks (20 students) and these marks have been keyed in (1-100 marks) it should print a histogram something like this.
0-29 *****
30-39 *****
40-69 *****
70-100 *****
This is what i've written so far and it doesn't seem so good.
#include <iostream>
using namespace std;
int main()
{
int i, j;
int count;
int Input, FirstInterval, SecondInterval, ThirdInterval;
cout << "How many marks did the student recieve?" <<endl;
cin >> Input;
if ( Input < 29 )
FirstInterval++;
for(i = 0; i < FirstInterval ; i++)count;
{
cout <<"*" << endl;
}
if ( Input < 39 )
SecondInterval++;
for(i = 0; i < SecondInterval ; i++)count;
{
cout <<"*" << endl;
}
if ( Input < 69 )
ThirdInterval++;
for(i = 0; i < ThirdInterval ; i++)count;
{
cout <<"*" << endl;
}
return 0;
}
What my program does is, it can key in the number but when it keys in any number it dots down 3 stars below the number.
28
*
*
*
[Please press any button to continue]
thats what comes up after i run my program.
Any assistance is appreciate thanks for your time.