Ticker

6/recent/ticker-posts

Program To Find Maximum Among 3 Numbers in JAVA

Program To Find Maximum Among 3 Numbers in JAVA:

There are various ways to find the maximum number among the three numbers in JAVA. To see the Algorithms you can go through the link given below:

Click Here to see Algorithms

The above Algorithms can be implemented in JAVA as follows:

Code 1:



public class max3 {
    public static void main(String[] args) {
        int abc;
        a = 5;
        b = 4;
        c = 3;
        if (a > b) {
            if (a > c)
                System.out.println("Max is A");
            else
                System.out.println("Maxi is C");
        } else {
            if (b > c)
                System.out.println("Max is B");
            else
                System.out.println("Max is C");
        }
    }
}

Code 2:



public class max3 {
    public static void main(String[] args) {
        int abc;
        a = 1;
        b = 2;
        c = 3;
        if (a > b && a > c)
            System.out.println("Max is A");
        else if (b > c)
            System.out.println("Max is B");
        else
            System.out.println("Max is C");
    }
}

Code 3:



public class max3 {
    public static void main(String[] args) {
        int abc;
        a = 1;
        b = 2;
        c = 3;
        if (a > b && a > c)
            System.out.println("Max is A");
        else if (b > a && b > c)
            System.out.println("Max is B");
        else
            System.out.println("Max is C");
    }
}

Don't forget to share it with your friends.

Post a Comment

1 Comments

  1. Nice collection of code 👌 keep it up!!!

    ReplyDelete