How to find greatest number in java using multiple If

//How to find greatest number in java using multiple If


import java.util.*;
public class M
{
public static void main(String args[])
{
int a,b;
System.out.println("Enter the value of a");
Scanner sc=new Scanner(System.in);
a=sc.nextInt();
System.out.println("Enter the value of b:");
b=sc.nextInt();
if(a>b)
{
System.out.println("a is greatest number");
}
if(a<b)
{
System.out.println("b is greatest number");
}
}
}


OUTPUT:
Enter the value of a
54
Enter the value of b:
25
a is greatest number

No comments:

Post a Comment