write a program to detect largest number
Answers
Answered by
0
Using scanner class
import java.util.Scanner;
public class largest
{
public static void main (String args[]
{
Scanner sc=new Scanner (System. in);
System. out. println("enter the first no");
int a=sc.nextInt();
System. out. println("enter the second no");
into b=sc.nextInt();
if(a>b)
{
System. out. println("first no is greater");
}
else
{
System. out. println("the second no is greater");
}
}
}
using main method
public class largest
{
public static void main( int a, int b)
{
if(a>b)
{
System. out. println("first nobody greater");
}
else
{System. out. println("second no is greater");
}
}
there r other methods but these are the commons
Similar questions