go to previous page   go to home page   go to next page hear noise highlighting

Answer:

Using the De Morgan Rule

!(A && B) is equivalent to !A || !B

the original expression

boolean reject = !(speed > 2000 && memory > 512)

is equivalent to

boolean reject = !(speed > 2000) || !(memory > 512)

which is equivalent to

boolean reject = (speed <= 2000) || (memory <= 512)

Another Demonstration

Here is the other De Morgan rule:

!(A || B) is equivalent to !A && !B

This truth table shows why this rule is true.

The fourth and the last column have the same truth values, which shows that the expressions at the top of those columns are equivalent.

A B (A || B) !(A || B) !A !B !A && !B
F F F T T T T
F T T F T F F
T F T F F T F
T T T F F F F

QUESTION 14:

Rewrite the following fragment:

while ( !(input.equals( "quit" ) || (count > limit)) ) 
{
   . . . 
}

go to previous page   go to home page   go to next page