The parentheses take precedence.
Take a look at the condition:
(!(money > 0 || reviews < 5 || reviews > 0))
First, the part inside the inner parenthesis are evaluated:
money > 0 || reviews < 5 || reviews > 0
Then, the order is from left to right:
money > 0
is false, continue to next;
reviews < 5
is true, so the expression in the inner parentheses is true.
The expression within the inner parentheses evaluates to true
, so effectively your condition is equal to !(true)
and that makes (false)
.
I suggest you study the basics of expression evaluation and operator precedence. Also, as pointed out by Ted Hopp, you need to rethink your logic. For example, I would rewrite expressions like !(money > 0)
to money <= 0
, to simplify it. In my opinion, it's best to not use the negation operator (!
) in conjunction with relational operators (like <
or ==
), unless you absolutely have to.
Note:
The && and || operators perform Conditional-AND and Conditional-OR operations on two boolean expressions. These operators exhibit "short-circuiting" behavior, which means that the second operand is evaluated only if needed.