go to previous page   go to home page   go to next page hear noise highlighting

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

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

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 =   

go to previous page   go to home page   go to next page