|
.. |
This page shows you a particular situation which requires two punctuation characters:
COMPARISON EXAMPLEWhenever you are doing a comparison of two values (with any of the comparison operators,<, less than
<=, less than or equal to
>, greater than
>=, greater than or equal to
==, equal to, or
!=, not equal to) you will need to put a left and right parentheses around
the operation. For example:
Box b ofType int -- Create an integer box named 'b'.
Outputln "Enter a num:" -- Ask your user to enter a number.
Input b -- Read in their number.
If (b < 0) then -- NOTICE: parentheses around the comparison
Outputln " negative"
ElseIf (b == 0) then -- NOTICE: again, parenthese are required
Outputln "zero"
Else
Outputln "positively"
EndIf
-- You are not expected to understand this example on your
-- first day. But you may want to return here sometime
-- during your first week.
|
|||||||||||
|
Return to JJ home page | .. |