Computer Applications

Write a program to print the largest of three numbers.

Java

Java Conditional Stmts

57 Likes

Answer

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

Answered By

32 Likes


Related Questions