+ 1

Parking fee problem solution

Output is ok. But they said something wrong. I can't find the problem. fun main(args: Array<String>) { var hours = readLine()!!.toInt() var total: Double = 0.0 if(hours >5 && hours<24){ total = 5+(hours -5)*0.5 }else if(hours >24){ total =total+15*(hours/24)+0.5*(hours%24) }else if(hours<=5){ total= total*hours } println(total) }

14th Oct 2021, 12:27 PM
Milon
Milon - avatar
3 Respuestas
+ 4
else if(hours<=5){ total= 1.0*hours }
14th Oct 2021, 2:48 PM
Simba
Simba - avatar
+ 2
Simba Thanks ❤️
14th Oct 2021, 2:53 PM
Milon
Milon - avatar
0
fun main(args: Array<String>) { var hours = readLine()!!.toInt() var total: Double = 0.0 if(hours in 0..5){ total=hours*1.0 } else if(hours in 6 until 24){ total=5.0+((hours-5.0)*0.5) } else if(hours>24){ val x=hours/24 total=(15.0*x)+(hours-(x*24))*0.5 } else{ total=0.0 } println(total) }
15th Jan 2022, 12:56 PM
MIKEY
MIKEY - avatar