The Answer is...

Report a typo

There is a try-catch-finally expression that stores the parsed value of the Int type in the answer variable. If an exception occurs during the reading process, answer must be equal to 42. Regardless of the value of answer, the following text must be printed: "The answer is a number".

Fix the code below to make it work as described.

Sample Input 1:

2

Sample Output 1:

The answer is a number
2

Sample Input 2:

Is that all you've got to show for seven and a half million years' work?

Sample Output 2:

The answer is a number
42
Write a program in Kotlin
fun main() {
val answer : Int = try { readLine()!!.toInt() } catch { 0 }
Finally { println("The answer is a number") }
println(answer)
}
___

Create a free account to access the full topic