Recap - Simple Logic
Part of the Fundamentals section of Coddy's Kotlin journey. Lesson 28 of 93.
Challenge
EasyWrite 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 orderisPremiumMember(Boolean): Whether the customer is a premium memberhasPromoCode(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
4Operators Part 1
Arithmetic OperatorsModulo OperatorAugmented AssignmentComparison OperatorsRecap - Simple Math7Basic IO
Println FunctionString TemplatesReadLine InputType ConversionRecap - Years Until RetirementRecap - True or False10Functions
Declare A FunctionParameters And ArgumentsReturn ValuesNamed ArgumentsDefault ValuesSingle Expression FunctionsRecap - Sigma FunctionRecap - Validation Function2Variables
Val vs VarType InferenceNumbersStringBooleanNaming ConventionsRecap - Initialize Variables5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Logical Operators Part 3Ternary With If ExpressionRecap - Simple Logic8Bill Split Calculator
Welcome MessageGetting Input3Nullability
What Is Null SafetyNullable TypesSafe Call OperatorElvis OperatorFunction Challenge BasicsNot Null AssertionRecap - Safe Access6Decision Making
If StatementIf - ElseIf As An ExpressionWhen ExpressionWhen With RangesRecap - Simple Calculator9Loops
For LoopWhile LoopDo-While LoopBreakContinueRanges In LoopsNested LoopRecap - FactorialRecap - Dynamic InputPractice on your own: Kotlin playground