Name:
CS 120 Quiz 3
Tom Linton, Spring 1999, Moravian College
-
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;
-
Write a boolean expression which tests whether or not the char
ch is a lowercase letter.
-
Write a boolean assignment statement which assigns true
to the boolean variable isLessThan, whenever x < y, and assigns
false otherwise.
-
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.