Section 3. Chapter 3
single
Challenge: Checking Delivery Eligibility
Swipe to show menu
Task
Swipe to start coding
Now it's your turn to practice using comparison operators and logical operators together. In this challenge, you'll complete a small coffee shop "delivery approval" system.
Your program should:
- Create variables for:
- The total order amount (
18) - Whether the delivery driver is available (
true) - Whether the customer has premium delivery (
false) - Whether there is a free delivery day (
true)
- The total order amount (
- Use comparison operators to check if the order amount is greater than
15. - Use comparison operators to check if the customer currently has premium delivery.
- Use logical operators to check whether the order qualifies for delivery — the order should qualify if:
- The driver is available AND
- The order amount is greater than
15AND - Either: the customer has premium delivery OR it is a free delivery day
- Print:
- Whether the order amount is greater than
15 - Whether the customer has premium delivery
- Whether the order qualifies for delivery Output should be as follows:
- Whether the order amount is greater than
Order amount greater than 15:
true
Customer has premium delivery:
false
Order qualifies for delivery:
true
Solution
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 3
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat