Kotlin Program to Find the Largest Among Three Numbers

bookmark

fun main(args: Array<String>) {

    val n1 = -4.5
    val n2 = 3.9
    val n3 = 2.5

    if (n1 >= n2 && n1 >= n3)
        println("$n1 is the largest number.")
    else if (n2 >= n1 && n2 >= n3)
        println("$n2 is the largest number.")
    else
        println("$n3 is the largest number.")
}
 

 

Output:

3.9 is the largest number.