You have two numbers, 4.5 as a Float and 5 as a Long, and you need to add them together in a Kotlin program. How would you properly reorder the lines of code to display the sum as a float, making sure the operations handle the different data types correctly?
When different types meet: type coercion
Summing Digits: A Tale of Types
Report a typo
Reorder lines using drag or arrows. Adjust indentation with left buttons
val number1: Float = 4.5f
fun main() {
}
println(result.toString() + "\n")
val result: Float = number1 + number2
val number2: Long = 5L
___
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.