+ 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) }
3 Antworten
+ 4
else if(hours<=5){
total= 1.0*hours
}
+ 2
Simba Thanks ❤️
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)
}