Friday, December 2, 2011

C++ help!!! Need help making a horizontal bar chart?

Trying to make a program that prints out a horizontal bar chart, I have done most of it and I need to call a function that prints out * corresponding to the user input. This is what I have so far.





#include %26lt;iostream%26gt;


#include %26lt;iomanip%26gt;


using namespace std;








void printArray(int a[], int count);








int main(){


const int MAX = 20;


int numbers[MAX];


int count = 0;


int input;











cout %26lt;%26lt; "Enter up to 20 positive numbers, 0-70(Enter -1 to stop)" %26lt;%26lt; endl;


do {


cout %26lt;%26lt; "enter a number: ";


cin %26gt;%26gt; input;


if ( input != -1 ) {


numbers[count++] = input;


if (input %26gt; 70 || input %26lt;= -2) {


cout %26lt;%26lt; "You entered an incorrect number, (0-70) and only positives" %26lt;%26lt; endl;


}


}


}while (input != -1 %26amp;%26amp; count %26lt; MAX);


printArray(numbers, count);





}





void printArray(int a[], int count){


cout %26lt;%26lt; "-------------------" %26lt;%26lt; endl;


for ( int i = 0; i %26lt; count; i++ ) {


cout %26lt;%26lt; setw(2) %26lt;%26lt; i %26lt;%26lt; " - " %26lt;%26lt; setw(2) %26lt;%26lt; a[i] %26lt;%26lt; ":" %26lt;%26lt; endl;


}


}|||if you have a recent edition of Microsoft word (I'm talking 2003+) you can do this....





Insert %26gt; Chart %26gt; (then it will offer you a bunch of chert types and styles)





Hope that helped x|||If I told you how easy it is to get a job in this recession, you wouldn't believe me. But the truth is more employers are going online to find people just like you and me who are ready to work at a good job (one that pays good!). The only thing that makes sense is to stop wasting time driving around all day filling out a dozen applications and going from one boring low paying job to another. I found this site that pretty much matches you up with your dream job that is available in your city right now. I have found it very helpful. Go to FindMeJobNow.com

No comments:

Post a Comment