Class Exercise: Boolean Expressions
Relational Operators: The operators you may employ when responding to the
following questions include: ==, !=, >, <, >=, <=
(note: the exclamation point (!) means "not")
For the following logical (Boolean) expressions, state the meaning and
the value resulting from the comparison. Note: do a search to find an
ASCII character table for code values to determine collating sequence.
Expression Meaning Value
-------------- ---------------------------- --------------
12 > 11
3.4 < 4.3
'a' <= 'A'
5.6 >= 5.59
1 != 1
'b' > 'B'
Evaluate the following expressions where variables
found = false, flag = true
ch = 'B'
x = 6.5, y = 4.3
nbr = 0, a = 5, b = 6;
Expression Meaning Value
-------------- ---------------------------- --------------
!found
x < 6.0
!nbr
found && (x >= 0)
('A' <= ch && ch <= 'C')
Boolean Expressions: Code expressions for the following comparisons:
1. the floating point variable discount is less than 5.0 .
2. the char variable answer equals the char literal 'y'
3. the boolean variable isValid equals the keyword false
4. the integer variable days is greater than zero
5. the integer variable score is greater than or equal to 90
6. the integer variable quantity is less than or equal to reorderPoint