Could someone explain to me why this happens? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Could someone explain to me why this happens?

This code works, but I couldn't finishing this exam because the Output are suppose (0.0), but they are give me this (0.0, Kotlin.Unit )-Output. So I don't know way the system prints Kotlin.Unit ? Code: https://code.sololearn.com/cqzxiu9SZz6d Input: 99.8 false fun shippingCost(amount: Double, inter: Boolean) { if(amount < 75.0 && !inter) { println((10.0 * amount) / 100.0) } else if (inter) { var num = (15.0 * amount / 100.0) if (num > 50.0) { num = 50.0 } println(num ) } else if ( amount > 75.0 && !inter) { println(0.0) } } // inter significa international fun main(args: Array<String>) { val total = readLine()!!.toDouble() val inter = readLine()!!.toBoolean() println(shippingCost(total, inter)) }

18th Feb 2022, 1:59 AM
Daniel Fernandez
Daniel Fernandez - avatar
3 Answers
+ 3
O wohw, you code works, and you wrote it super nice and legible🪶, I loved it, I'm going to read it and re-read it to learn to write like that, I really loved it, thank you very much for your kind help🙏🏻.
18th Feb 2022, 4:07 AM
Daniel Fernandez
Daniel Fernandez - avatar
+ 2
You killing me 🤣, I'm using this (10.0 * amount) / 100.0), and jut super simple -> amount * 0.1. 🤣, thank you I'm learn so much with you code TY🙏🏻
18th Feb 2022, 4:17 AM
Daniel Fernandez
Daniel Fernandez - avatar
0
I'm ready try this solution first, but the sistem geve me another error in the last key, and I do not know way? For that I'm trying with the println.
18th Feb 2022, 3:04 AM
Daniel Fernandez
Daniel Fernandez - avatar