Voting simulator

This is a template I'm trying to tweak and change the output to the '*' output instead of the percentage.

#include <iostream>
#include <string>
using namespace std;

void InitializeData();

int main()
{
InitializeData();
cout<<endl;

return 0;


}

void InitializeData()
{
string array1[1000];
int n;
int counter;
int votes[10000];

cout<<"how many candidates are you counting: ";
cin>>n;

while(n<2 || n>10)
{
cout<<endl;
cout<<"Please enter between 2 and 10 candidates";
cin>>n;
}


cout<<endl<<"Please Enter Their Names:";
cout<<endl;
for( counter=0; counter<n; counter++)
{
cin>> array1[counter];
cout<<endl;
}
cout<<"Enter The Amount Of Votes For Each Candidate";
for( counter=0; counter<n; counter++)
{
cin>> votes[counter];
cout<<endl;
}
cout<<"Your candidates are as follows"<<endl<<endl;
for( counter=0; counter<n; counter++)
{
cout<<array1[counter];
cout<<endl;



}
int totalVotes = 0;
for (counter = 0; counter < n; counter++)
{
totalVotes += votes[counter];
}

cout << "The vote percentages are as follows:" << endl << endl;
for (counter = 0; counter < n; counter++)
{
cout << array1[counter] << ": " << static_cast<float>(votes[counter])/static_cast<float>(totalVotes) * 100 << endl;
}

}
Last edited on
change the output to the '*' output instead of the percentage.

I don't know what that means.
Do you mean "output a histogram"?

Why is array1 dimensioned as 1000 when you can only have 10 candidates?
Why is votes dimensioned as 10000 when you can only have 10 candidates?

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Topic archived. No new replies allowed.