+ 1
What's wrong with this code?
fun main(args: Array<String>) { var hours = readLine()!!.toInt() var total: Double = 0.0 if(hours>5 && hours<24){ total += (5+((hours-5)*.5)) } else if(hours>=24){ total += (15+((hours-24)*.5)) } else{ total += hours } println(total) }
3 Answers
+ 2
If this is the "Parking Fee" code coach in Kotlin, well this is not an easy one.
I won't give you a straight solution, but others will do đ
đđ€Ł and you won't understand anything.
What I can tell you is to be more careful at the second else if. Also, you can use "when" keyword.
total = when {
hours <= 5 -> hours * 1.0;
hours <= 24 && hours > 5 -> ...
else -> ...
}
Good luck!
+ 2
Ancient Lynx See?! If all the SoloLearn users would understand that giving right away the solution and not a small or a big hint is not the way of becoming a better programmer, than this community will be great.
+ 1
Thanks Romeo Cojocaru ... Your suggestion helped me a lot and I got the answer !! You are great !