Can't pass the parking tree problem in kotlin | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can't pass the parking tree problem in kotlin

Please does anyone knows how i can pass the parking tree problem in kotlin? After passing the first and second test case, the other cases refused to open meanwhile my code is correct. Please does anyone knows what I'll do to open the remaining test cases? or maybe only sololearn pro users have access to it?

6th Apr 2021, 2:06 AM
404
4 Answers
+ 1
Show us the code so we can help you. If your code were correct, it would've passed all test cases. Also, you can't open the remaining test cases for your own good.
6th Apr 2021, 2:07 AM
Soumik
Soumik - avatar
+ 2
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) }
6th Apr 2021, 2:25 AM
404
+ 1
Here is the code
6th Apr 2021, 2:26 AM
404
+ 1
What happens if someone parks for 2 days or longer? The math isn't right. You'll need to calculate out all the days for the 24 hour rate. Then 0.5 for the balance. If someone parked for 55 hours. That would be 2 days and 7 hours.
6th Apr 2021, 4:09 AM
Jerry Hobby
Jerry Hobby - avatar