Help with a poll problem.


Here's exactly what the problem asks.

Write a program that provides the option of tallying up the results of a poll with 3 possible values. The first input to the program is the poll question; the next three inputs are the possible answers. The first answer is indicated by 1, the second by 2, the third by 3. The answers are tallied until a 0 is entered. The program should then show the results of the poll-try making a bar graph that shows the results properly scaled to fit on your screen no matter how many results were entered.

There is probably a much easier way than using the if statements I have but I don't know what else to use. I am unsure what I need to do to tally the results at the end. I'm assuming it's some sort of count algorithm. And I have no idea how to make a bar graph. :{ Help please.

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
44
45
46
  #include <iostream>

using namespace std;
int main()
{

    while (true)
    {
        int input;
        char riding=1;
        char golfing=2;
        char reading=3;
        char done=0;


        cout<<"Please type the name of one of the following options you enjoy the most\n0. Enter done to end poll and see results\n1. Hunting\n2. Fishing\n3. Drinking\n";
        cin>>input;

    if (input==1)
    {
        cout<<"You chose riding as the activity you enjoyed the most\n";
    }
    if(input==2)
    {
        cout<<"You chose golfing as the activity you enjoyed the most\n";
    }
    if(input==3)
    {
        cout<<"You chose reading as the activity you enjoyed the most\n";
    }
    if (input==0)
       {


            cout<<"Poll has ended.\n Results:\n";
            break;
       }

    if(input!=0||1||2||3)
    {
        cout<<"Please enter a valid option\n";
    }

    }
}
Line 39 is wrong.
http://www.cplusplus.com/faq/beginners/logic/#or-vs-select

As for tallying, there is nothing to tally yet. your program does not store results of the multiple answers anywhere. Make at least two questions and store results somewhere.
Topic archived. No new replies allowed.