0

Help with Kotlin Parking Fee project

so ive been trying to make this work for a while and currently i want to die, i dont know whats goin wrong since the only test cases its failing is hidden also the code is ridiculously bad ik pls help fun main(args: Array<String>) { var hours = readLine()!!.toInt() var amountDue = 0.0 if (hours <= 5) { amountDue = hours * 1.0 } else { amountDue = 5 * 1.0 var remainingHours = hours - 5 amountDue += remainingHours * 0.5 } var numDays = hours / 24 var fullDays = numDays.toInt() amountDue += fullDays * 0.5 println(amountDue) }

25th Dec 2022, 2:13 AM
lance
1 Answer
+ 2
if(hours <= 5){ amountDue = hours * 1.0 } else if (hours > 5 && hours < 24){ amountDue = ((hours-5.0)*0.5)+5.0 } else { amountDue= (15.0 * Math.floor(hours /24.0)) + ((hours% 24.0)*0.5) }
25th Dec 2022, 2:24 AM
Lwez
Lwez - avatar