what is wrong in my code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is wrong in my code

this is the problem:: 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 and this is my code . Please check it : fun main(args: Array<String>) { var hours = readLine()!!.toInt() var total: Double = 0.0 if(hours<24) if(hours<=5) total = hours * 1.0 else total = 5.0 + (hours - 5) * 0.5 else if(hours==24) total = 15.0 else total = 15.0 + (hours - 24) * 0.5 }

7th Mar 2022, 9:19 AM
chaima laissaoui
1 Answer