In a console-based Kotlin application, you need to read two integer values from standard input, calculate their sum, and print it to the console. The application must be robust against invalid input, delivering a user-friendly error message instead of crashing when non-numeric values are entered. To fulfill these requirements, fill the blanks in prepared code bases provided, ensuring its correctness and robustness.
Errors in programs
Calculating sum of two integers with error handling
Report a typo
Fill in the gaps with the relevant elements
fun main() {
{
val num1: Int = Integer.parseInt(readLine())
val num2: Int = Integer.parseInt(readLine())
println("Sum of numbers : ${num1 + num2}")
} (e: ) {
println("Invalid number was inputted")
}
} ___
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.