My program is nearly done but I need a little help

So I was reading from my book "Jumping into C++" doing an exercise for loops in which I had to make a poll with three voting options and in the end would tally the votes and somehow make a bar graph to represent the number of votes if the user enters 0 and would then show it...I assume that we need to use a symbol to represent the vote numbers like * for every vote...this is all i have so if someone knows how to add something like this I would very much appreciate your help
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

[/c#include <iostream>
#include <string>
using namespace std;

int main ()
{
    cout << "What do you think of the PS4\n";
    int choice,first,second,third;
    first = 0;
    second = 0;
    third = 0;
    
    cout << "1. The PS4 will be the best system\n2. Xbox will be the better system\n3. I'll stay with what I have\n";
    cin >> choice;
    while (choice ==1 || choice ==2 || choice ==3 || choice==0) {
        
        if (choice ==1) {
            
        first++;
        cout << "one vote for PS4 is the best system\n";
            cin >> choice;}
        if (choice ==2) {
            
            second++;
            cout << "one vote for the xbox being better\n";
            cin >>choice;}
        if (choice ==3) {
            third++;
            cout << "One vote that you will stay with current gen\n";
            cin >> choice;
        }
        if (choice == 0) {
            cout << "Voting has ended" << endl;
            break;
        }
    
    }
}
Last edited on
it's rather simple to print the stars:
1
2
3
4
5
for(int i = 0; i < x; ++i)
{
  cout << '*';
}
cout << endl;


I suggest that you make it a function and pass first, second, third as a parameter.
Thanks coder it helped!
Topic archived. No new replies allowed.