- 1

Suggestions on errors?

Doesnt work for a couple of tests..not sure where the mistake is fun main(args: Array<String>) { var hours = readLine()!!.toDouble() var total: Double = 0.0 total = when { hours in 0.1..5.0 -> 1.0 * hours hours in 5.1..24.0 -> ((hours-5.0)*0.5)+5.0 else -> 15.0+((hours-24.0)*0.5) } println(total) } Any help will be greatly appreciated

26th Feb 2021, 3:29 PM
Andrea Botticini
Andrea Botticini - avatar
2 Antworten
+ 2
24 hours = 14.50 in your code should be 15.0 48 hours = 27.0 should be 30.0
26th Feb 2021, 3:43 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
that's great. thanks for the help guys.
26th Feb 2021, 4:38 PM
Andrea Botticini
Andrea Botticini - avatar