Summing Digits: A Tale of Types

Report a typo

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?

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
              
___

Create a free account to access the full topic