Find Largest Of Three Numbers Using If-Else | Java Programs

Output:

*** Largest Number Among 3 Numbers ***

The 3 Number Are: 1243, 120, 7029

7029 is the largest Number

Click Here For Java Online Compiler

Solution:

public class LargestOf3NumbersUsingIfElse {

    public static void main(String[] args) {

        int num1 = 1243, num2 = 120, num3 = 7029;
        System.out.println("*** Largest Number Among 3 Numbers ***" + "\n");
        System.out.println("The 3 Number Are: " + num1 + ", " + num2 + ", " + num3);
        System.out.println();

        if (num1 >= num2 && num1 >= num3) {
            System.out.println(num1 + " is the largest Number");
        } else if (num2 >= num1 && num2 >= num3) {
            System.out.println(num2 + " is the largest Number");
        } else {
            System.out.println(num3 + " is the largest Number");
        }
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon