Question 1 Report
The food-delivery program checks a discount voucher before the order is confirmed. A voucher is valid when the customer is new, or when the order total is at least 30 pounds and the customer has entered a loyalty code. The comparisons and input check return Boolean values. The programmer proposes validVoucher = newCustomer OR (largeOrder AND loyaltyCode). A test user is not new, has a large order, and has entered no loyalty code. Another user is new with a small order and no code.
(a) Explain why the large-order and loyalty-code tests are joined by AND. [2]
(b) When the first test user has values False, True, False, state the value of validVoucher. [1]
(c) When the second user has values True, False, False, state the value of validVoucher. [1]
(d) Explain one reason for using brackets in this statement. [2]
The condition is newCustomer OR (largeOrder AND loyaltyCode). AND requires both inputs to be True; OR requires at least one input to be True.
AND.largeOrder AND loyaltyCode is False, and False OR False is False. [1]True OR (...) is True. [1]largeOrder AND loyaltyCode into one condition. [1] That grouped result is then combined with newCustomer using OR, making the intended logic clear. [1]Everything you need to excel in your exams