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.

15. Oil Change


Answer:

Using the De Morgan Rule

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

the original expression

    while ( !(input.equals( "quit" ) || (count > limit)) ) 
    {
       . . . 
    }

is equivalent to

    while ( !input.equals( "quit" ) && !(count > limit)) ) 
    {
       . . . 
    }

which is equivalent to

    boolean reject = (speed <= 2000) || (memory <= 512)

Oil Change

The owner's manual for a car says to change the oil every three months or every 3000 miles.

boolean newOilNeeded =  months >= 3 || miles >= 3000 ; 

Here is an expression that shows when no oil change is necessary:

boolean oilOK =  !( months >= 3 || miles >= 3000 ); 

Question 15:

Rewrite the last expression using one of De Morgan's rules. Do this in two steps. In the first step, don't change the relational expressions.

    boolean oilOK =

Now further simplify by changing the relational expressions.

    boolean oilOK =