0

Why does test caes 3 isn't working properly??

fun shippingCost(amount: Double, international: Boolean) { if(international == true) { println(amount*15/100) } else if(international == false && amount>=75) { println(0.0) } else if(amount < 75) { println(amount*10/100) } } fun main(args: Array<String>) { val total = readLine()!!.toDouble() val international = readLine()!!.toBoolean() shippingCost(total, international) } You are working on a eCommerce website and need to make a shipping cost calculator based on the order amount. The store uses the following cost structure: For orders in the US: - $75+ orders have free shipping - orders less than $75 have a shipping fee of 10% of the total order amount. 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.

28th Jul 2021, 2:43 PM
Shahir
Shahir - avatar
3 Answers
+ 6
Shaik.Shahir , the calculation for international shipping does not take in account, that $50 is the limit that should be calculated for this.
28th Jul 2021, 3:55 PM
Lothar
Lothar - avatar
+ 4
Shaik.Shahir , here is my explanation : // this is the part of the code that calculates the shipping cost if 'international' shipping has to be done. let us assume that the total amount is $900 .... fun shippingCost(amount: Double, international: Boolean) { if(international == true) { println(amount*15/100) } .... the resulted and printed value is: $135. this us 15% from 900. but the task description mentioned, that the maximum shipping fee for international destination should be $50.
29th Jul 2021, 10:49 AM
Lothar
Lothar - avatar
+ 1
Sorry I didn't get it ! Plz explain me once again
29th Jul 2021, 4:06 AM
Shahir
Shahir - avatar