+ 1
I need help to the answer on the Parking Fee Task with explanation.
Help me
3 Antworten
+ 3
First case should be hours<=5 not <=1
And multyplied by 1.00 I think? Not 0.5
And for the last case, you need all full days (24h) * 15 plus the hours longer the last 24h * 0.5
Example 50 hours = 2 * 24h + 2h
=> 2 * 15 + 2 * 0.5
+ 1
show your attempt.
0
fun main(args: Array<String>) {
var hours = readLine()!!.toInt()
var total: Double = 0.0
if ( hours <= 1) {
total = 0.5 * hours
} else if (hours >= 5 && hours <= 23) {
total = 5.00 + (hours - 5) * 0.5
} else {
total = 15.00 + (hours - 24) * 0.5
}
println(total)
}