( Relational and Logical Operators ) Relational and Logical operators are often
ID: 3803514 • Letter: #
Question
( Relational and Logical Operators )
Relational and Logical operators are often included in the looping conditions of repetition code blocks.
The following table lists several variables from a Java program and the value of each variable at the point where a condition is about to be evaluated.
Variable Name
Variable Type
Contents
item_number
String
C22
quantity
Numeric
65
price
Numeric
4.75
reorder_point
Numeric
20
discount
String
N
What is the value for each of the following conditions?
Enter T for TRUE or F for FALSE.
____ (a) (quantity > = 100) && (price = = 4.75)
____ (b) (quantity < 100) || (price = = 4.75)
____ (c) (price > = 4.75) || (quantity = = 50 && discount = = 'N')
____ (d) ((quantity = = 50) && (discount = = 'N')) && (price == 1.0)
____ (e) quantity = = 65 || ((discount = = 'Y') && (price = = 4.75))
____ (f) (reorder_point == 20) && (quantity == 50) || (price < 0.5)
Variable Name
Variable Type
Contents
item_number
String
C22
quantity
Numeric
65
price
Numeric
4.75
reorder_point
Numeric
20
discount
String
N
Explanation / Answer
(a) (quantity > = 100) && (price = = 4.75)
Answer: False
(quantity > = 100) && (price = = 4.75) means False && True = False
(b) (quantity < 100) || (price = = 4.75)
Answer: True
(quantity < 100) || (price = = 4.75) means True || True = True
(c) (price > = 4.75) || (quantity = = 50 && discount = = 'N')
Answer: True
(price > = 4.75) || (quantity = = 50 && discount = = 'N') means True || (False && True ) = True || False = True
(d) ((quantity = = 50) && (discount = = 'N')) && (price == 1.0)
Answer: False
((quantity = = 50) && (discount = = 'N')) && (price == 1.0) Means False && (True && False) = False && False = False
(e) quantity = = 65 || ((discount = = 'Y') && (price = = 4.75))
Answer: True
quantity = = 65 || ((discount = = 'Y') && (price = = 4.75)) means True || (False && True) = True || False = True
(f) (reorder_point == 20) && (quantity == 50) || (price < 0.5)
Answer: False
(reorder_point == 20) && (quantity == 50) || (price < 0.5) means True && False || False = False
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.