0
i need help, give me a code to solved it :(
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. You need to complete the given shippingCost() function, which takes the order amount and a Boolean indicating whether the order is international or not, and returns the shipping cost for that order. The return amount should be a Double. Sample Input: 140.0 true Sample Output: 21.0
4 Respostas
+ 5
You typed toBoolean() function and println() in a same line.
You need to keep a space between two different lines or use a semicolon to separate them.
fun main() {
val total = readLine()!!.toDouble()
val international = readLine()!!.toBoolean();println(shippingCost(total, international))
}
+ 3
|[CNC]| ArCH. ExoTesla ,
please don't ask the community to do this job for you. to get ready codes does not really help you to progress in learning and it does not develop your problem solving ability.
we will give you no ready-made code, but if you show us your attempt we will be glad help you.
to do so, we need to see your code to find out the issues you have. if you have not done any code so far, please do so.
=> put your code in playground and link it here
thanks!
+ 3
Simba
thanks friend...
i'm try it and very helpful for me..
0
Simba Lothar
looking my code, what's wrong :(
fun shippingCost(amount: Double,
international: Boolean): Double {
var shipcost:Double
if (international == false) {
shipcost = 0.0
if (amount < 75.0) {
shipcost = amount*0.1
}
} else {
shipcost = amount*0.15
if (shipcost > 50.0) {
shipcost = 50.0
}
}
return shipcost
}
fun main() {
val total = readLine()!!.toDouble()
val international = readLine()!!.toBoolean() println(shippingCost(total, international))
}