//Write a Program to Find Greatest Number of Three Number in Java. import java.io.*;
class greatest
{
public static void main(String
args[])
{
int a,b,c;
a=13;
b=11;
c=12;
if (a>b)
{
if (a>c)
{
System.out.print(“A is greatest
Number and the Value is =”+a);
}
else
{
System.out.print(“C is greatest
Number and the Value is =”+c);
}
}
else
{
if(b>c)
{
System.out.print(“b is greatest
Number and the Value is =”+b);
}
else
{
System.out.print(“A is greatest
Number and the Value is =”+a);
}
}
}
}
Output:
A is greatest Number and the
Value is =13
|
Using Scanner Class
//Write a Program to Find Greatest Number of Three Number in Java.
import
java.io.*;
import
java.util.*;
class
greatest
{
public
static void main(String args[])
{
int
a,b,c;
Scanner
sr=new Scanner(System.in);
System.out.print(“Enter
the value of First Number);
a=sr.nextInt();
System.out.print(“Enter
the value of Second Number);
b=sr.nextInt();
System.out.print(“Enter
the value of Third Number);
c=sr.nextInt();
if
(a>b)
{
if
(a>c)
{
System.out.print(“A
is greatest Number and the Value is =”+a);
}
else
{
System.out.print(“C
is greatest Number and the Value is =”+c);
}
}
else
{
if(b>c)
{
System.out.print(“b
is greatest Number and the Value is =”+b);
}
else
{
System.out.print(“A
is greatest Number and the Value is =”+a);
}
}
}
}
Output:
A is
greatest Number and the Value is =13
|