# Truth Tables and De Morgan's Rules

## 17. Full Price Hotel

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`

.`In the second step, rewrite the relational expression:`

boolean discount =

boolean discount =