.Write a program in java to accept two numbers from the user and print the smaller number
Answers
Answered by
1
Answer:
import java.util.Scanner; //importing the scanner class
class acc
{
Scanner sc=new Scanner(System.in); //creating a scanner class object
public void main(String args[])
{
System.out.println("enter the first number");
int a=sc.nextInt(); //taking the first number
System.out.println("enter the second number");
int b=sc.nextInt();
System.out.println("the numbers you have entered are "+ a+ " " + b);
if(a>b)
{
System.out.println(a+" is greater than "+b);
}else if(b>a)
{
System.out.println(b+" is greater than "+ a);
}
}
}
Explanation:
If you have any problem in this program do let me know
Similar questions