JAVA
Write a program in Java to find maximum of three numbers using conditional operator
import java.util.Scanner;
class LargestOfThreeNumbers
{
public static void main(String args[])
{
int x, y, z, max;
System.uot.println("Enter three integers");
Scanner in = new Scanner(System.in);
x= in.nextInt();
y= in.nextInt();
z= in.nextInt();
max = x> y ? (x>z?x:z) : (y>z?y:z);
System.out.println("Maximum of three is:"+max);
}
}
0 Comments