Hail. I'm having trouble with this program...here is the discription...
Description: Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values. The program should read in an arbitrary number of integers that are in the range 1 – 100 inclusive, then produce a chart similar to the one below that indicates how many input values fell in the range of 1 to 10, 11 – 20, and so on. Print one asterisk for each value entered. After the histogram has been displayed, allow the user to clear the screen and create another one as many times as he wishes.
1 – 10 | **************************
11 – 20 | ***
21 – 30 |******
31 – 40 |**
41 – 50 |*
51 – 60 |
61 – 70 |************************************
71 – 80 |***
81 – 90 |****************
91 – 100 | **
Now heres the code that i have dont so far.
#include <iostream>
#include <iomanip>
using namespace std;
//local constants
int quit = -1;
//local variables
int data;
/**************************start main program*********************/
int main()
{
const int arraySize = 15;
int array[arraySize] = {0};
for(int a = 0; a < arraySize; a++)
{
if(a == 0)
cout <<"Enter a number please.\n";
else
cout <<"Enter another number please.\n";
cin >> array[a];
}
cout<<"Here are the details of your entries.\n"
<<"Element"<<setw(20)<<"Value"
<<setw(25)<<"Histogram"<<endl;
for(int i = 0; i < arraySize; i++)
{
cout<<setw(7)<<i<<setw(20)<<array[i]<<setw(17);
for(int j = 0; j < array[i]; j++)
cout <<"*";
cout <<endl;
}
system("PAUSE");
return 0;
}
--------------------------------------------------------------
My questions and what i need help with is ...
-How can i make the array any size, so it can quit on the 2nd number entered or the 27th number entered?
-How can i make it look how its suppose to be. I coded it this way because i wanted something to post and im not sure how i can make it so its the correct way as in discription.
Thanks in advance