This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Boolean Values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Boolean Values" Watch "Boolean Values" New topic
Author

Boolean Values

Roger Sanchez
Greenhorn

Joined: Jun 23, 2003
Posts: 16
A couple of other questions in preparation for an exam:
( ( x || ! ( y && z ) ) && ! ( y || z) )

( ( ! x && ( y || z ) ) || ( ! y || z))

Thanks again,
Roger
Paul Zill
Greenhorn

Joined: Jun 12, 2003
Posts: 28

not sure what the question is.
did you forget the values for x, y, & z?
Jaunty John
Greenhorn

Joined: Jul 14, 2002
Posts: 21
These will always resolve false if NOT true


(((o o)))<br />""--^--"" Entropy is Increasing...
Paul Zill
Greenhorn

Joined: Jun 12, 2003
Posts: 28
Originally posted by Jaunty John:
These will always resolve false if NOT true

if what not true
if:
boolean x = true;
boolean y = false;
boolean z = true;
than the first example would be true.
and second false.
if:
boolean x = false;
boolean y = false;
boolean z = true;
the the first is false and the second is true.
Roger Sanchez
Greenhorn

Joined: Jun 23, 2003
Posts: 16
I forgot to put the variable values:
x = false, y = true, z = false
( ( x || ! ( y && z ) ) && ! ( y || z) )

x = false, y = true, z = false
( ( ! x && ( y || z ) ) || ( ! y || z))
Thanks again
Joe Pluta
Ranch Hand

Joined: Jun 23, 2003
Posts: 1376
They might be trying to simplify the equation.
For example, take this one:
( ( x || ! ( y && z ) ) && ! ( y || z) )
If either y or z is true, this statement is false (because the right side of the *AND is false). So, plug false values for y and z into the left expression, getting (x || true), which removes x from the equation.
The whole thing factors downs to (!y && !z).
Similarly, after some careful manipulation, the second statement is (!x || !y || z).
Don't believe me? You could always try a truth table <grin>.
Joe
Roger Sanchez
Greenhorn

Joined: Jun 23, 2003
Posts: 16
Thanks for the quick reply. So, to check my understanding, both statements are false?
Joe Pluta
Ranch Hand

Joined: Jun 23, 2003
Posts: 1376
Nope. First is false, second is true. Quick runthrough:
x = false, y = true, z = false
( ( x || ! ( y && z ) ) && ! ( y || z) )
( ( F || ! ( T && F ) ) && ! ( T || F ) )
( ( F || ! ( F ) ) && ! ( T ) )
( ( F || T ) && F )
( T && F )
F
x = false, y = true, z = false
( ( ! x && ( y || z ) ) || ( ! y || z))
( ( ! F && ( T || F ) ) || ( ! T || F ) )
( ( T && T ) || ( F || F ) )
( T || F)
T

Joe
 
 
subject: Boolean Values
 
Similar Threads
boolean x = (a = true) || (b = true) && (c = true);
How does this code works ?
Why does count not reflect # of tokens?
Strange IF condition
scjp chapter 5 q...5 page no 303