QuestionQ8

Using Operators and Decision Constructs

Given the following code fragment:

Question Image

And the following requirements:

  • If the value of the qty variable is greater than or equal to 90, discount = 0.5.
  • If the value of the qty variable is between 80 and 90, discount = 0.2.

Which two code fragments can independently be placed at line n1 to meet these requirements?

Question Image

Choose two
  • A Option A
  • B Option B
  • C Option C
  • D Option D
  • E Option E
Explanation

The conditions must preserve discount = 0.5 for every qty value of 90 or more, while assigning discount = 0.2 only for values greater than 80 and less than 90. Separate non-overlapping if statements or a conditional expression that tests qty >= 90 before qty > 80 satisfy those ranges.

Community Discussion

No comments yet. Be the first to start the discussion!