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 shipping =  !(purchase >= 50 && !onSale ); 

is equivalent to

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

which can be further transformed to

boolean shipping =  purchase < 50  || onSale ; 

Full Price Hotel

A hotel charges full price for its rooms during the "on season" when a reservation is made less than 14 days in advance. Otherwise, a reservation qualifies for a discount.

boolean fullFare = (days < 14) && onSeason;

Assume that onSeason is a boolean variable. Here is an expression that says when a discount rate may be available:

boolean discount = !( (days < 14) && onSeason );

QUESTION 17:

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

boolean discount =   

In the second step, rewrite the relational expression:

boolean discount =   

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