Write a program to print the largest of three numbers.

Write a program to print the largest of three numbers.

public class KboatLargestNumber
{
    public static void largestNumber(int a, int b, int c) {
        System.out.println("The three numbers are " 
               + a + ", " + b + ", " + c);
        
        System.out.print("Largest Number: ");
        if (a > b && a > c)
            System.out.println(a);
        else if (b > a && b > c)
            System.out.println(b);
        else
            System.out.println(c);
    }
}
Output

 

BlueJ output of KboatLargestNumber.java

Comments