# Jumping into C++ PracticeH Problem

• 11-18-2012
Sid_TheBeginner
Jumping into C++ PracticeH Problem
Hello Guys. Please help me code this practice problem. Its from Alex Allain's Jumping into C++. A really cool book :)

© Alex Allain (C programming.com - Learn C and C++ Programming - Cprogramming.com)
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.

here's my code:
Code:

```#include<iostream> using namespace std; int main() {     int reply;     int one, two, three = 0;     int step = 0;     while(1)     {         cout << " What do you think of the\n"                        " Politician ABC?:\n"                 " 1. Nothing, 2. He's an idiot!\n"                 " 3. He's awesome!, 0. Get me outta here!!\n";         cin >> reply;         if(reply == 0)         {                 break;         }         if(reply == 1) one++;     /*    if(reply == 2) two++;         if(reply == 3) three++; */                 }         cout << "Graph:\n";     cout << " % .\n"; // trying to draw the Y-Axis     cout << "20 .\n";     cout << "15 .\n";     cout << "10 .\n";     cout << "05 .\n";     cout << "00 .\t";         step = 0; cout << "\$";     if(one <= 5 && one <= 9) step = 1; cout << "\$";     /*else if(one == 10) step = 2; cout << // m trying to plot a graph for only option 1. Hence this part is commented     else if(one == 15) step = 3;     else if(one = 20) step = 4;        if(step == 0) cout << "#\n"     if(step == 1) cout << " */     cout << "\nThanks for your input.\n"                 "Press ENTER to quit.";     cin.ignore();     cin.get(); }```
This one seems quite tough :confused:

Thanks,
Sid
• 11-18-2012
Stevan
Hello,
First thing, you didn't even initialized one and two, cause
Code:

`int one,two,three=0`
isn't equal to one=0,two=0,three=0,you just initialized three.
While loop seems ok, i would only put some new lines in the pool quesiton. For the graph part, try using for loop, and also count how many times did while loop occured.
• 11-19-2012
Sid_TheBeginner
I'm sorry for posting it like crazy I'll work on it more and ask more precise questions..