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) }

9th Jul 2021, 1:36 PM
Aryan Ahmed Adil
Aryan Ahmed Adil - avatar
4 Antworten
+ 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) }
9th Jul 2021, 3:15 PM
Simba
Simba - avatar
+ 1
Thanks, that worked 😊
9th Jul 2021, 3:20 PM
Aryan Ahmed Adil
Aryan Ahmed Adil - avatar
0
Simba still it doesn't work
9th Jul 2021, 2:35 PM
Aryan Ahmed Adil
Aryan Ahmed Adil - avatar