+ 1

Parking Fee (Kotlin) , Do I've any error in this code ?

fun main(args: Array<String>) { var hours = readLine()!!.toInt() var total: Double = 0.0 var i:Int = 0 if (hours in 0..23) { while (hours >= 5) { hours -= 5 i++ break } total += (hours * 0.5) + i*5 println(total) } else { while (hours >= 24) { hours -= 24 i++ } total += (hours * 0.5) + i*15 println(total) } }

2nd Aug 2021, 5:51 AM
Nikunj Vashishtha
Nikunj Vashishtha - avatar
2 Antworten
+ 4
Yes, There is no output if hours < 5
2nd Aug 2021, 5:56 AM
Simba
Simba - avatar
0
Simba show solution lets see
8th Aug 2021, 8:59 PM
Ejeh Wayne
Ejeh Wayne - avatar