Yes/No votes using loops

The output is supposed to horizontal and there should be no number, how would I fix this?
I need the output to be something like this:
1
2
3
Enter a string of YES and NO votes: yyNNNYYnn
   YES votes: ****
   NO votes : *****




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

#include <iostream> 
#include <iomanip> 
#include <string>

using namespace std;

int main()
{
	int type;
	int Yc=0.0, Nc=0.0;  
	char votes;

	//Enter table
	cout << "Enter a string of YES and NO votes: ";

	for(int i=1; i<=10; ++i)
	{ cin >> votes; 
		switch (votes)
		{
		case 'y': case 'Y': Yc++; break;
		case 'n': case 'N': Nc++; break; 
		}
	}
	//Count of Yes Votes
	cout << " YES VOTES: " << Yc;  
	for(int i=1; i<=Yc; ++i)
	{	
		cout <<  "*"; 
	}
	cout << endl;
	
	//Count of No Votes
	cout << " NO VOTES : " << Nc ;  
	for(int i=1; i<=Nc; ++i)
	{	
		cout <<  "*"; 
	}
	cout << endl;
	//end program
	system("pause");
	return 0;
}
Last edited on
What problem are you having? Can't you just remove Yc from line 26 and Nc from line 34?
Does it have to be a loop, a simple std::getline could do the trick, like such http://ideone.com/YjkE3L
Oh ya forgot, don't know why I put that. thanks.
Topic archived. No new replies allowed.