0

{KOTLIN} Parking Fee Problem. Why will my code not pass cases 5 and 6?

fun main(args: Array<String>) { var hours = readLine()!!.toInt() var total: Double = 0.0 var day = (hours / 24) total += day * 15 var prhr = hours % 24 if (prhr > 5 && day > 0) { total += prhr * 0.5 } else if (prhr > 5) { total += 5.0 + ((prhr-5)*0.5) } else { total += (prhr * 1.0) } println("%.1f".format(total)) }

23rd Mar 2022, 10:36 PM
Areeb Qureshi
3 ответов
+ 2
Delete "prhr > 5" from: if (day > 0) { total += prhr * 0.5 }
23rd Mar 2022, 11:05 PM
Solo
Solo - avatar
+ 2
I'm glad I was able to help you, subscribe to me for further follow-up of my comments and answers to questions. 😎
23rd Mar 2022, 11:53 PM
Solo
Solo - avatar
+ 1
That worked ! Thank you
23rd Mar 2022, 11:11 PM
Areeb Qureshi