This is a Java Program to Accept two Integers and Check if they are Equal.
Enter two integer numbers as input. After that we match both the inputs with the help of equal to(==) operator. Hence we generate the output accordingly.
Here is the source code of the Java Program to Accept two Integers and Check if they are Equal. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
import java.util.Scanner;
public class Equal_Integer
{
public static void main(String[] args)
{
int m, n;
Scanner s = new Scanner(System.in);
System.out.print("Enter the first number:");
m = s.nextInt();
System.out.print("Enter the second number:");
n = s.nextInt();
if(m == n)
{
System.out.println(m+" and "+n+" are equal ");
}
else
{
System.out.println(m+" and "+n+" are not equal ");
}
}
}
Output:
$ javac Equal_Integer.java $ java Equal_Integer Enter the first number:5 Enter the second number:7 5 and 7 are not equal Enter the first number:6 Enter the second number:6 6 and 6 are equal
Sanfoundry Global Education & Learning Series – 1000 Java Programs.
advertisement
Here’s the list of Best Books in Java Programming, Data Structures and Algorithms.
Related Posts:
- Practice Information Technology MCQs
- Check Programming Books
- Check Java Books
- Practice BCA MCQs
- Apply for Computer Science Internship