+ 1
Parking Fee(Kotlin)
fun main(args: Array<String>) { var hours = readLine()!!.toInt() var total: Double = 0.0 if (hours<=5){ total += hours println(total) } else if (hours>=5 && hours <24){ total = 5.0 hours -= 5 total += (hours*0.5) println(total) } else if (hours>=24){ total = 15.0 hours -= 24 total += (hours*0.5) println(total) } } I can't get where is my mistake? Some test corrects. Uncorrect test are locked, so i can't see where i did mistake
3 Answers
+ 1
thank you, redone my code.
0
Hope these helps..
Greater than 24 case think if input is 50hr, means 2days + 2 hours..
https://www.sololearn.com/discuss/3017156/?ref=app
https://www.sololearn.com/discuss/2999649/?ref=app
0
qop
I can see 2 errors before I even start testing.
1. if hours <= 5
elsif hours >= 5
You have written a piece of code that has 2 options if hours = 5
2. Each day costs 15, but you charge 15 for day 1 & 12 for day 2
I suggest you look at ascertaning the number of days, then the residual hours
days x 15
hours x 0.5