0
Help! What is the mistake here?
// See. Learn - > control Flow -> 17 Code project "Parking free" fun main(args: Array<String>) { var h = readLine()!!.toInt() var t: Double = 0.0 if(h>=24 && h%24==0){ t=h/24*15.0 }else if(h>=24 && h%24 in 1..23){ var b=h%24; t=(h-b)/24*15.0+b*0.5 }else if(h<24){ if(h/5<1){ t = h*0.5 }else{ t= if(h==5) 5.0 else 5+(h-5)*0.5 } } println(t) }
3 odpowiedzi
+ 2
Please tag the relevant programming language and the course name.
+ 2
/*
The fee is calculated based on the following price structure:
- the first 5 hours are billed at $1 per hour.
- after that, each hour is billed at $0.5 per hour.
- for each 24 hours, there is a flat fee of $15.
*/
Consider the following case:
I park my 🚗 for 4 hours. Hence I should pay $4.
According to your code, I would only need to pay
b = 4%24 = 4
t = (4–4)*15 + 4*0.5 = 2
0
This language - Kotlin.17 lesson task "cost of parking"