0
Parking Fee, KOTLIN, what's wrong with this code?
It only passed test 1, test 2 and test 4 but failed test 3, test 5 and test6 fun main(args: Array<String>) { var hours = readLine()!!.toInt() var total: Double = 0.0 total = when{ hours == 24 -> 15*1.0 hours > 5 && hours < 24 -> ((hours-5)*0.5)+5 hours > 24 -> ((hours-24)*0.5)+15 else -> hours*1.0 } println(total) }
4 Respuestas
+ 4
I mean
fun main(args: Array<String>) {
var hours = readLine()!!.toInt()
var total: Double = 0.0
total = when{
hours == 24 -> 15*1.0
hours > 5 && hours < 24 -> ((hours-5)*0.5)+5
hours > 24 ->((hours%24)*0.5)+(hours/24*15)
else -> hours*1.0
}
println(total)
}
+ 1
Thanks, that worked 😊
0
Simba still it doesn't work