Java Program to find Max & Min number, Write a program in Java Language to find maximum & minimum numbers
Program
class maxmin
{
public static void main(String args[])
{
int no1,no2,ans;
no1 = Integer.parseInt(args[0]);
no2 = Integer.parseInt(args[1]);
Logic L=new Logic();
ans=L.find(no1,no2);
if (ans == no1)
System.out.println("No1 Is Greater Than No2...." );
else
System.out.println("No2 Is Greater Than No1...." );
}
}
class Logic
{
public int find(int n1, int n2)
{
return( n1 > n2 ? n1 : n2); // Conditional Operator
}
}
No comments:
Post a Comment