+ 1

(Kotlin)Check it please dears. I dont know where i done wrong

fun main() { var hours = readLine()!!.toInt() var total: Double = when{ hours < 5 && hours >= 0 -> 0.5 * hours hours >=5 && hours < 24 ->5 + (hours - 5) * 0.5 hours >= 24 -> 15 * (hours / 24) + (hours % 24) * 0.5 else -> 0.0 } println(total) }

8th Mar 2021, 11:11 AM
Hamdambek🖥️🎧
Hamdambek🖥️🎧 - avatar
3 Antworten
+ 3
why } after the else?I dont see any bracket opening in your code
8th Mar 2021, 11:15 AM
Sharique Khan
Sharique Khan - avatar
+ 3
If hours <=5 , it should be hours *1.0 not 0.5*hours
8th Mar 2021, 11:45 AM
Simba
Simba - avatar
+ 1
Thank u! ohh i made a mistake in copying. But not true yet
8th Mar 2021, 11:21 AM
Hamdambek🖥️🎧
Hamdambek🖥️🎧 - avatar