Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Checking Delivery Eligibility | Operators and Conditionals
Introduction to Java
Section 3. Chapter 3
single

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:

  1. 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)
  2. Use comparison operators to check if the order amount is greater than 15.
  3. Use comparison operators to check if the customer currently has premium delivery.
  4. 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 15 AND
    • Either: the customer has premium delivery OR it is a free delivery day
  5. 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:
Order amount greater than 15:
true
Customer has premium delivery:
false
Order qualifies for delivery:
true

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 3
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt