Here is a program that uses the round function according to this logic: if the input number is greater than or equal to 1000, it returns null, otherwise it returns the number. Do not change the round function: fix the output. It has to return 0 in null case.
Avoiding NPEs. Null safety
Safe round
Report a typo
Sample Input 1:
-5Sample Output 1:
-5Sample Input 2:
5000Sample Output 2:
0Write a program in Kotlin
fun main() {
val number = readln().toInt()
println(round(number))
}
// do not change function below
fun round(number: Int): Int? {
return if (number >= 1000) null else number
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.