Menu
Coddy logo textTech

Recap - Simple Logic

Part of the Fundamentals section of Coddy's Kotlin journey. Lesson 28 of 93.

challenge icon

Challenge

Easy

Write a function canGetFreeShipping that takes orderTotal, isPremiumMember, and hasPromoCode and returns whether a customer qualifies for free shipping.

A customer gets free shipping if their order total is at least 50 and they are either a premium member or have a promo code.

Parameters:

  • orderTotal (Int): The total value of the order
  • isPremiumMember (Boolean): Whether the customer is a premium member
  • hasPromoCode (Boolean): Whether the customer has a promo code

Returns: true if the customer qualifies for free shipping, false otherwise (Boolean)

The supplied driver calls your function and prints its returned value. Keep the function signature and do not add a main function.

Try it yourself

fun canGetFreeShipping(orderTotal: Int, isPremiumMember: Boolean, hasPromoCode: Boolean): Boolean {
    // Write code here
}

All lessons in Fundamentals

Practice on your own: Kotlin playground