In this page you can learn to check the given two numbers are equal or not. The steps are given below
- First create the java class with the main class.
- Declare the two variables in the integer.
- Use the scanner function to get the input number from the user.
- Then use the if statement to check the numbers are equal.
- When the number is equal use the print statement to print the numbers are equal.
- Otherwise it will go to the else statement.
- In the else statement it will print as the given numbers are not equal.
Program to check the two numbers are equal or not
import java.util.Scanner;
class Equal{
public static void main(String args[]){
int number1,number2;
Scanner a=new Scanner(System.in);
number1=a.nextInt();
number2=a.nextInt();
if(number1==number2)
{
System.out.println("The given two numbers are Equal");
}
else
{
System.out.println("The given two numbers are not Equal");
}
}
}
Input-1:
2
2
Output-1:
The given two numbers are Equal
Input-2:
5
7
Output-2:
The given two numbers are not Equal
إرسال تعليق