+ 1

What is the error in it???

fun main(args: Array<String>) { var h = readLine()!!.toInt() if(5<=h && 24>=h) { var f = h-5 println(5+(f*0.5)) } else if(h>24) { var g = h-24 println(15+(g*0.5)) } if(h==5) { println(5.00) } if(h==24) { println(15.00) } }You are making a car parking software that needs to calculate and output the amount due based on the number of hours the car was parked. 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. This means, that, for example, if a car parked for 26 hours, the bill should be 15+(2*0.5) = 16.0, because it was parked for 24 hours plus 2 additional hours. Sample Input: 8 Sample Output: 6.5 Explanation: The first 5 hours are billed at $1/hour, which results in $5. After that, the next 3 hours are billed at $0.5/hour = $1.5. So, the total would be $5+$1.5 = $6.5

27th Jul 2021, 8:11 AM
Shahir
Shahir - avatar
2 Respostas
+ 1
I cannot promise that will work (sorry) but there may be a syntax error issue as (from what I understand) a colon is needed in-between the variable name and the data type.
28th Jul 2021, 9:09 PM
noah hulvey
+ 1
There for it may not be able to detect the variable. ( Again, your probably way more qualified than me, but I am just trying to help.)
28th Jul 2021, 9:12 PM
noah hulvey