Write a program in Java to find maximum of three numbers using conditional operator.

 

AIM:   Write a program in Java to find maximum of three numbers using conditional operator.

 

CODE:

public class max

{

            public static void main(String args[])

            {

                        int n1=Integer.parseInt(args[0]);

                        int n2=Integer.parseInt(args[1]);

                        int n3=Integer.parseInt(args[2]);

                        int max=0;

                        max=(n1>n2 && n1>n3)? n1:((n2>n3)?n2:n3);

                                    System.out.println("Max="+max);

            }

}

 

OUTPUT:



Comments

Popular posts from this blog

Describe abstract class called Shape which has three subclasses say Triangle, Rectangle, and Circle. Define one method area()in the abstract class and override this area() in these three subclasses to calculate for specific object.

Write a program in Java to perform I/O operations on a Text file.

Write an application that illustrates method overriding in the same package and different packages. Also demonstrate accessibility rules in inside and outside packages