+ 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) }
3 Antworten
+ 3
why } after the else?I dont see any bracket opening in your code
+ 3
If hours <=5 , it should be hours *1.0 not 0.5*hours
+ 1
Thank u! ohh i made a mistake in copying. But not true yet