Write a program to accept 2 number and display
smallest with out using Math method.
Answers
Answered by
1
Answer:
import java.util.*;
public class SmallestNumber
{
public static void main(String args[ ])
{
Scanner in=new Scanner(System.in);
int a,b;
System.out.println("Enter the numbers");
a=in.nextInt();
b=in.nextInt();
if(a<b)
{
System.out.println("The smaller number="+a);
}
else if(a>b)
{
System.out.println("The smaller number="+b);
}
else
{
System.out.println"Both the numbers are equal");
}
}
}
Note:The last statement in program you have to write as if you write 2 equal numbers then I will give a error in the program ok.
Hope it helps....
Similar questions