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 expression

boolean oilOK =  !( months >= 3 || miles >= 3000 ); 

is equivalent to

boolean oilOK =  !( months >= 3 ) && !( miles >= 3000 ); 

which can be further transformed to

boolean oilOK =  ( months <  3 ) &&  ( miles <  3000 ); 

Free Shipping

For an on-line shopping site, shipping is free for purchases of $50 or more, unless the merchandise is on sale.

boolean freeShipping =  purchase >= 50 && !onSale; 

Here is an expression that shows when to charge for shipping:

boolean shipping =  !( purchase >= 50 && !onSale ); 

Assume that onSale is a boolean variable.


QUESTION 16:

Rewrite the second expression in two steps. In the first step, apply De Morgan's rule that !(A && B) is equivalent to !(A) || !(B).

boolean shipping =   

In the second step, rewrite the relational expression:

boolean shipping =   

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