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 ;
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 );
Rewrite this expression in two steps.
In the first step, apply De Morgan's rule that !(A&&B)
!(A)||!(B)
boolean discount =
In the second step, rewrite the relational expression:
boolean discount =