Java Reference
In-Depth Information
IF (((X = Y) OR (Z < X)) AND
((Z NOT = Y) OR (X NOT < 1)))
DISPLAY "Condition is true"
ELSE
DISPLAY "Condition is not true".
Notice the liberal use of parentheses in the Java example and the use of
curly braces around the if and else code blocks, even though these con-
structs may not be strictly required.
What Java operator can you reverse in order to make the “Condition is
true” message appear?
13. I'll experiment a bit with additional data types. Add these bolded lines to
the end of your HelloWorld class:
// Experiment with additional data types.
// These data types are automatically converted to the double data type
// during the comparison.
double d = 4;
float f = 4;
short s = 4;
if ((d == y) && (d == f) && (d == s)) {
System.out.println ("Condition is true");
}
else {
System.out.println ("Condition is not true");
}
Compile and rerun the HelloWorld application. The output should look
like this:
...
testMsg = ErrorMsg text
i = 5
z = 8
Condition is not true
Condition is true
14. Try a test involving overflow of integer values. Add these bolded lines to
the end of your HelloWorld class:
Search WWH ::




Custom Search