if ( car.price <= 8000 ) System.out.println("Affordable"); else System.out.println("Too Expensive!");

Augustus De Morgan was a nineteenth century British mathematician
who showed the importance of several rules of logic.
Two of these,
**De Morgan's Rules**, show how the NOT operator can be moved to the inside of an expression.
(Although these rules are named after De Morgan, they were, in fact, known to Aristotle.)

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

These rules are very useful. Make sure you know them.

This truth table shows why the first rule is true.

A | B | (A && B) | !(A && B) | !A | !B | !A || !B |
---|---|---|---|---|---|---|

F | F | F | T | T | T | T |

F | T | F | T | T | F | T |

T | F | F | T | F | T | T |

T | T | T | F | F | F | F |

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

Rewrite the following fragment (from a previous example):

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