+ 1
Could you help me with this code?
fun main(args: Array<String>) { var hours = readLine()!!.toInt() var total: Double = 0.0 for(i in 1..hours){ if(i>5&&i<24){ total+=0.5 } else if(i<=5){ total+=1.0} else if(i==24){ total+=15.0 } else if(i>24){ total+=(i-24)*0.5 } } println(total)}
3 odpowiedzi
+ 2
Hello,
Your code compiles and runs.
Can you describe your problem?
Also please save your code in the playground and insert a link.
+ 1
Ok I got it thank you for your answer
0
According to the task description in the "Parking Fee" code project of Kotlin lesson 17
If the time exceeds 24 hours, then the total fee is 15 for every whole day, plus 0.5 for each additional hour. Your calculation does not reflect this case correctly.