Showing posts with label greater. Show all posts
Showing posts with label greater. Show all posts

Sunday, November 2, 2014

, , , ,

Program to print greater number in 3 numbers using if else in command line argument.




Code Box
-----------------------------------------

/* Program to print greater number in 3 numbers using 
if else in command line argument */


class greaterif3
{
public static void main(String x[])
{
int a,b,c;

a=Integer.parseInt(x[0]);
b=Integer.parseInt(x[1]);
c=Integer.parseInt(x[2]);

if(a>b && b>c)
{
System.out.print("\n a is greater a="+a);
}
else
if(b>c)
{
System.out.print("\n b is greater b="+b);
}
else
{
System.out.print("\n c is greater c="+c);
}

}

}
Publisher: Brijmohan Lal Sahu - 3:35 AM
, , , ,

Program to print greater number in 2 numbers using if else in command line argument.



Code Box
-----------------------------------------

/* Program to print greater number in 2 numbers using 
if else in command line argument */


class greaterif
{
public static void main(String x[])
{
int a,b;

a=Integer.parseInt(x[0]);
b=Integer.parseInt(x[1]);

if(a>b)
{
System.out.print("\n a is greater a="+a);
}
else
{
System.out.print("\n b is greater b="+b);
}

}

}
Publisher: Brijmohan Lal Sahu - 3:32 AM
, , ,

Program to print greater number in 3 numbers using conditional operator in command line argument.



Code Box
-------------------------------------

/* Program to print greater number in 3 numbers using 
conditional operator in command line argument */


class greaterc3
{
public static void main(String x[])
{
int a,b,c;

String s;

a=Integer.parseInt(x[0]);
b=Integer.parseInt(x[1]);
c=Integer.parseInt(x[2]);

s=(a>b && b>c)?"a is greater a="+a:((b>c)?"b is grater b="+b:"c is grater c="+c);

System.out.print("\n"+s);

}

}
Publisher: Brijmohan Lal Sahu - 3:29 AM
, , , ,

Program to print greater number in 2 numbers using conditional operator in command line argument.



Code Box
-----------------------------------------

/* Program to print greater number in 2 numbers using 
conditional operator in command line argument */


class greaterc
{
public static void main(String x[])
{
int a,b;

String s;

a=Integer.parseInt(x[0]);
b=Integer.parseInt(x[1]);


s=(a>b)?"a is greater a="+a:"b is grater b="+b;

System.out.print("\n"+s);

}

}
Publisher: Brijmohan Lal Sahu - 3:26 AM