Suppose you are given two integers entered by the user. Your task is to create a Kotlin program that calculates the sum of these two integers, then increment the sum by one and output the result. The expected input comes from the Standard Input using the Java Scanner technique and the output must be a phrase indicating the incremented sum. You need to reorder the lines of code to solve the problem efficiently adhering to Kotlin best practices. Your solution should handle the basic integer operations seamlessly.
Integers in action
Sum two integers and increment the total by one
Report a typo
Reorder lines using drag or arrows. Adjust indentation with left buttons
println("Enter first integer:")
sum++
fun main() {
println("The incremented sum of two integers is $sum")
println("Enter second integer:")
import java.util.Scanner
}
val num1 = scanner.nextInt()
val scanner = Scanner(System.`in`)
val num2 = scanner.nextInt()
var sum = num1 + num2
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.