Reputation: 177
I'm trying to create an if statement that validates that the user's bet is either exactly 100, 300 or 500. What am i doing wrong?
if ((roundBet != 100) || (roundBet != 300) || (roundBet != 500))
{
cout << "Incorrect input";
// Call round again
newRound();
}
Upvotes: 0
Views: 62
Reputation: 122373
if ((roundBet != 100) || (roundBet != 300) || (roundBet != 500))
This will evaluates as true
for all roundBet
, because a number is either not 100(roundBet != 100
true) or 100 (which is not 300, roundBet != 300
true)
What you need is:
if ((roundBet != 100) && (roundBet != 300) && (roundBet != 500))
Upvotes: 1
Reputation: 24780
One of the alternatives will always be true, since if roundBet
is, say, 100
, then it will be different from 300
and 500
.
Use a logical AND &&
Upvotes: 0