Name ______________________

Assume the following:

int k = 10;
int j = 6;
boolean b = false;
boolean c = true

I.                   Show what is printed by each of the following statements.

1.      _____F_____ System.out.println( 1 > 2 );

2.      _____F_____ System.out.println( b );

3.      _____T_____ System.out.println( !b );

4.      ____T______ System.out.println( k > j && j != 5 );

5.      ____F______ System.out.println( k/2 >= j && j/2 == 3 );

6.      ____T______ System.out.println( k > j && c );

7.      _____T_____ System.out.println( k < j || j != 5 );

8.      _____F_____ System.out.println( k < j || j == 5 );

9.      ____F______ System.out.println( !(k > j && j != 5) );

 

III. .Write an if statement that does the following:

(a)    When the variable x is between 3 and 5, print "GREAT".

if (x > 3 && x < 5)

{

             System.out.println("GREAT"):

}

(b)   When the variable x is between 3 and 5, print "GREAT". Otherwise, print "NOT SO GOOD"

if (x > 3 && x < 5)

{

             System.out.println("GREAT"):

}

      else

     {

                   System.out.println("NOT SO GOOD"):

      }

(c)    When the variable x is between 3 and 5 print GREAT. If it is 3 or below, print "LITTLE". If it is 5 or greater, print "BIGGER".

if (x > 3 && x < 5)

{

             System.out.println("GREAT"):

}

      else if (x <=3)

     {

                   System.out.println("LITTLE"):

      }

      else

     {

                   System.out.println("BIGGER"):

      }