+ 2
Hey guys I have a problem in parking fee problem of Kotlin
all the test is working except test 4, please if anyone solved the problem before share your code.
5 Respuestas
+ 2
Seyyed Ali Mahdi The output is expected to be float so the problem is your first if where you test hours <= 5 and then print hours which is an int. Try println(hours * 1.0)
+ 3
First share your attempt so we can help you debug the code.
+ 3
fun main(args: Array<String>) {
var hours = readLine()!!.toInt()
var total: Double = 0.0
var day = 0
if(hours <= 5){
println(hours)
}else if(hours > 5 && hours<24){
println(5 + (hours-5)*.5)
}else if(hours == 24){
println(15)
}else {
var d = hours / 24
day = d.toInt();
var x = day*15
println((x)+((hours - day*24)*.5) )
}
}
+ 3
It worked thanks❤
+ 2
You're welcome.