Hi all,
Total newbie here and having problems with an assignment from class. Need to incorporate a WHILE (loop) and an IF condition while keeping track of voting. I thought I was doing this write but I can't break out of my loop. Any help is nice. Please be kind, I am only 4 weeks into this.
*Keep in mind I need to adhere to simple logic with basic commands. I understand there are probably 5 different ways to do this better. THANKS for the help all. I hope to start contributing here soon.
CONCEPT
The conept is to ask the user to vote for one of three descrete items. Let the user keep voting while keeping track of the number of votes. If the user types done, show total number of votes. My thought was to determine whether the user has typed done first, then break to totals if YES. WHen I type done, I keep getting ERROR #1 from loop instead of IF statement outside of loop. I have a feeling this is a simple logic problem that I cant wrap my head around.
string vote;
int pop_COUNT=0, cand_COUNT=0, nach_COUNT=0;
I added a value to the string vote when setting variables.
string vote = "done";
It works now but I have NO IDEA why? Still looking for some feedback or explanation on why setting the variable EQUAL to the value that my loop is looking for made this work. Glad its working but need to know why otherwise, I won't learn. THanks
Well it should give you error #1 as you didn't enter one of the three options. After that, though, it should exit the loop and give you the total votes. Note that error #2 is actually impossible as it is; you can't leave the loop without vote being "done".
And yes, please use [code][/code] tags and indentation.