## Truth Tables and De Morgan's Rules

Read this chapter, which discusses Boolean variables as used in decision tables. Truth tables are used to collect variables and their values relative to decisions that have to be made within control structures.

### 14. Another Demonstration

Answer:Using the De Morgan Rule!(A && B) is equivalent to !A || !Bthe original expressionboolean reject = !(speed > 2000 && memory > 512)is equivalent to
boolean reject = !(speed > 2000) || !(memory > 512)which is equivalent toboolean reject = (speed <= 2000) || (memory <= 512)

# Another Demonstration

Here is the other De Morgan rule:

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

This truth table shows why this rule is true.

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

A
B
(A || B)
!(A || B)
!A
!B
!A && !B
F
F
F
T
T
T
T
F
T
T
F
T
F
F
T
F
T
F
F
T
F
T
T
T
F
F
F
F

Question 14:Rewrite the following fragment:while ( !(input.equals( "quit" ) || (count > limit)) )
{
. . .
}