Name:
CS 120 Quiz 3
Tom Linton, Spring 1999, Moravian College


  1. What is the value of x after the following Java statements are executed?
      x = 10.0;
      y = x / 2.0;
      if ( y != (x - 5.0) )
         x = x + 2.0;
      else
         x = x - 2.0;

     
     
  1. Write a boolean expression which tests whether or not the char ch is a lowercase letter.




     
  1. Write a boolean assignment statement which assigns true to the boolean variable isLessThan, whenever x < y, and assigns false otherwise.

  2.  

     
     
     
     
     
     
     

  3. Write Java statements which prompt the user for an integer from -5 to 5, and then displays "non-negative" whenever the user enters zero or a positive value, and displays "negative" if they enter a negative value.