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
3 Antworten
+ 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;
}
+ 1
Thanks Simba
+ 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))
}