0

[SOLVED] How can pass three test in shipping Calculator kotlin

I can't pass the three test course Kotlin https://code.sololearn.com/c85oRoq9oPgk/?ref=app

3rd Jul 2021, 1:39 PM
Benjamin Salas
Benjamin Salas - avatar
3 Respostas
+ 4
For international orders, there is a 15% shipping fee, with a maximum of $50. This means that the maximum shipping fee for an international order is $50. if (international){ if (amount*0.15 >= 50){ return 50.0; }
3rd Jul 2021, 2:28 PM
Simba
Simba - avatar
+ 1
Thanks Simba
3rd Jul 2021, 2:44 PM
Benjamin Salas
Benjamin Salas - avatar
+ 1
For international is true and 15 percentage of amount is greater than 50 then fun will return 50 as tax else will return 15 percentage of amount. And if international is false then amount is greater than 75 then tax will be 0.0 and if amount less than 75 then tax will be 10 percentage of amount fun shippingCost(amount: Double, international: Boolean): Double { if (international){ if (amount * 0.15 > 50){ return 50.0; } else { return amount * 0.15; } } else{ if (amount > 75){ return amount * 0; } else { return amount * 0.10; } } } fun main(args: Array<String>) { val total = readLine()!!.toDouble() val international = readLine()!!.toBoolean() println(shippingCost(total, international)) }
5th Dec 2022, 5:11 PM
Aswathi KT
Aswathi KT - avatar