without using if else and ternary operators,accept three unequal no. and display the second smallest no. use Math.max,math.min. input.34,82,61
Answers
Answered by
152
class abc
{
public static void main()
{
int a=82, b=34, c=61;
int x, y, z;
x = (int)Math.max(Math.max(a,b),c);
z = (int)Math.min(Math.min(a,b),c);
y = (a+b+c) - (x+z);
System.out.println("largest = "+x);
System.out.println("middle = "+y);
System.out.println("smallest = "+z);
}
}
{
public static void main()
{
int a=82, b=34, c=61;
int x, y, z;
x = (int)Math.max(Math.max(a,b),c);
z = (int)Math.min(Math.min(a,b),c);
y = (a+b+c) - (x+z);
System.out.println("largest = "+x);
System.out.println("middle = "+y);
System.out.println("smallest = "+z);
}
}
Answered by
10
Answer:
your answer is in the ATTACHMENT....
Attachments:
Similar questions