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)) }
3 odpowiedzi
+ 2
Delete "prhr > 5" from:
if (day > 0) {
total += prhr * 0.5
}
+ 2
I'm glad I was able to help you, subscribe to me for further follow-up of my comments and answers to questions. 😎
+ 1
That worked ! Thank you