//First Case
package Mobile.OperatorsAndExpressions;
import java.util.Scanner;
public class ConditionalOperator
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a,b,max;
System.out.println("Enter First Number");
a=sc.nextInt();
System.out.println("Enter Second Number");
b=sc.nextInt();
max=((a>b)?a:b);
System.out.println("Maximum of 2 is="+max);
}
}
package Mobile.OperatorsAndExpressions;
import java.util.Scanner;
public class ConditionalOperator
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a,b,max;
System.out.println("Enter First Number");
a=sc.nextInt();
System.out.println("Enter Second Number");
b=sc.nextInt();
max=((a>b)?a:b);
System.out.println("Maximum of 2 is="+max);
}
}
//Second Case
package Mobile.OperatorsAndExpressions;
import java.util.Scanner;
public class ConditionalOperator1
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a,b,c,max;
System.out.println("Enter First Number");
a=sc.nextInt();
System.out.println("Enter Second Number");
b=sc.nextInt();
System.out.println("Enter Third Number");
c=sc.nextInt();
max=((a>b)?((a>c)?a:c):((b>c)?b:c));
System.out.println("Maximum of 3 is="+max);
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.