+ 1

Can someone tell me what's wrong in this code....????

fun shippingCost (amount: Double, international: Boolean): Double { var cost = 0.0 if(international){ cost = if (amount*0.15 > 50) 50.0 else amount*0.15 } else if(amount<75) cost = amount*0.1 } return cost fun main(args: Array<String>) { val total = readLine()!!.toDouble() val international = readLine()!!.toBoolean() println(shippingCost (total, international)) }

16th Jul 2022, 8:21 PM
Gurmeet Kukreja
1 Answer
+ 2
Gurmeet Kukreja You have closed bracket } before the return cost Should be close after return. fun shippingCost (amount: Double, international: Boolean): Double { var cost = 0.0 if(international){ cost = if (amount*0.15 > 50) 50.0 else amount*0.15 } else if(amount<75) cost = amount*0.1 return cost }
16th Jul 2022, 10:29 PM
AÍąJ
AÍąJ - avatar