You are given a Kotlin program where two variables num1 and num2 are declared as Double and Int respectively, and a third variable sum is declared as Double. You need to calculate the sum of num1 and num2 and assign it to sum. Remember to handle the difference in data types before performing the summation. Reorder the lines of code to provide the correct output - 'The sum is 19.2'.
When different types meet: type coercion
Calculating sum of different data types
Report a typo
Reorder lines using drag or arrows. Adjust indentation with left buttons
}
val num2: Int = 4
val num1: Double = 15.2
val sum: Double = num1 + num2.toDouble()
println("The sum is $sum")
fun main() {
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.