How to find the given numbers are equal using java programming


 In this page you can learn to check  the given two numbers are equal or not. The steps are given below

  1. First create the java class with the main class.
  2. Declare the two variables in the integer.
  3. Use the scanner function to get the input number from the user.
  4. Then use the if statement to check the numbers are equal.
  5. When the number is equal use the print statement to print the numbers are equal.
  6. Otherwise it will go to the else statement.
  7.  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


0 تعليقات

إرسال تعليق

Post a Comment (0)

أحدث أقدم