Outside walls must be insulated with at least 4 inches of fiberglass batting or with at least 3 inches of plastic foam insulation.

A good answer might be:

    // check that at least one qualification is met
    if ( fiber >= 4 || foam >= 3 )
      System.out.println("House passes the code requirements!" );
    else
      System.out.println("House fails." );

Difference between AND and OR

Here is what would happen if a house had 6 inches of fiberglass batting and 0 inches of plastic foam:

fiber >= 4 || foam >= 3
---------    ---------
  true          false
   ---------------
        true
One true is enough.

AND is different from OR. Both of them combine Boolean values ( true/false values ) into one Boolean value. But each does it in a different way:

  • The values AND combines must all be true to get a true.
  • The values OR combines must have at least one true among them to get a true.

QUESTION 20:

Pick true or false for each of the following:
5 > 2 || 12 <= 7    
5 > 2 && 12 <= 7    
3 == 8 || 6 != 6    
3 == 8 && 6 != 6    
(Remember that != means "not equal.")
Click Here after you have answered the question