overlord20
Gawd
- Joined
- Feb 5, 2010
- Messages
- 623
Is it possible to use an 'or' statement in a while loop?
Once the user or computer wins 5 times then the loop ends. Is that possible? To my knowledge it isn't possible and when I execute it the loop goeas on for ever. When using an 'if' there instead of the 'while' it only runs once. But it will compile and execute.
This is to a much bigger project and I don't want it done for me. Just looking for a little assistance on this one little part. Thank you.
Code:
a=0
b=0
while ( a < 5 || b < 5)
{
if ( user == comp)
System.out.println("WIN);
a++;
if (comp == user)
System.out.println("WIN);
b++
}
Once the user or computer wins 5 times then the loop ends. Is that possible? To my knowledge it isn't possible and when I execute it the loop goeas on for ever. When using an 'if' there instead of the 'while' it only runs once. But it will compile and execute.
This is to a much bigger project and I don't want it done for me. Just looking for a little assistance on this one little part. Thank you.