Our code consists of 3 stages.
Stage 1 - In the car park, up to 5 hours fee is $ 1.
Stage 2 - After 5 hours, it drops to $ 0.50 per hour. If the car stays in the park for 6 hours, the fee is $ 5.50.
Stage 3 - the fee per day, taking into account the 1st and 2nd stages, is 14.50 cents. But we have to make the daily fee fixed as $ 15. If the car stays in the park for 25 hours, the price should be 15.50, not $ 15.
I wrote stages 1 and 2 above, as you can see in the code block. However, I could not write the daily fee, which is the 3rd stage.
fun main(args: Array<String>) {
var hours = readLine()!!.toInt()
var total: Double = 0.0
var price = 0.0
if (hours <= 5) {
price= 1.0
total = hours * price
println(total)
} else if (hours>=6) {
price= 0.5
total=hours*price-2.5+5.0
println(total)
}
}