So what are the requirements.
1. You want to read the user input
2. Evaluate the user input
3. Display the message whether or not he won
And that over and over again.
Hence, all code from personPlay = Keyboard.nextLine(); up until all the if else statements need to be in the loop.
Check this link: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/while.html
It explains the while loop pretty well. Also check the for loop.
If you then still have questions, ask ..
when i try to compile this I get a bunch of else without if errors at all my else if statements..... thoughts?
first evaluates the value and then increments. Hence prints 0;
first increments and then evaluates, hence prints 1.
i remains 0, because the evaluation happens first, is assigned to i, and then the incrementation happens which has no effect.
Simply use i++.
Bryan PeachShould they be static variables???[/quote wrote:Don't know. But if you haven't got a good reason for making something static, it probably shouldn't be.
You need to go through your loop and find where those variables are incremented. Also find whether you have managed to declare them twice.
Bryan Peach wrote:I'm am super confused... could you please just show me what you mean? I realize this might be a pain for you but I really don't understand the do while loop
It's not that its a pain... but generally people learn better when they try it out for themselves -- especially when they try it out and fail initially. There is no better way to burn something into the brain than frustration. So... I recommend that you just try it. And who knows? You may figure it out on the first attempt.
BTW, as a side note. I don't really know why, but the do-while loop seems to be the least popular among the loops. The for loop (both variants) and the while loop seems to be used more often.