package ConditionalOperatorExample;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ConditionalOperatorExample
{
public static void main(String[] arun) throws IOException
{
String s1,s2,s3;
int i1,i2,i3,Max,Min;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter first number; ");
s1 = br.readLine();
System.out.println("Enter second number: ");
s2 = br.readLine();
System.out.println("Enter third number: ");
s3 = br.readLine();
i1 = Integer.valueOf(s1).intValue();
i2 = Integer.valueOf(s2).intValue();
i3 = Integer.valueOf(s3).intValue();
Max = (i1>i2)?((i1>i3)?i1:i3):((i2>i3)?i2:i3);
System.out.println("Maximum number is "+Max);
Min = (i1 System.out.println("Minimum number is "+Min);
}
}
Output =>
Enter first number;
25
Enter second number:
3
Enter third number:
64
Maximum number is 64
Minimum number is 3
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ConditionalOperatorExample
{
public static void main(String[] arun) throws IOException
{
String s1,s2,s3;
int i1,i2,i3,Max,Min;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter first number; ");
s1 = br.readLine();
System.out.println("Enter second number: ");
s2 = br.readLine();
System.out.println("Enter third number: ");
s3 = br.readLine();
i1 = Integer.valueOf(s1).intValue();
i2 = Integer.valueOf(s2).intValue();
i3 = Integer.valueOf(s3).intValue();
Max = (i1>i2)?((i1>i3)?i1:i3):((i2>i3)?i2:i3);
System.out.println("Maximum number is "+Max);
Min = (i1
}
}
Output =>
Enter first number;
25
Enter second number:
3
Enter third number:
64
Maximum number is 64
Minimum number is 3
No comments:
Post a Comment