Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

import java.util.Scanner; public class IntEqual { // TODO - write your code belo

ID: 3896735 • Letter: I

Question

 import java.util.Scanner;  public class IntEqual {     // TODO - write your code below this comment.     // You need to define two methods, the first of which     // has the following properties:     // - The method's name is areEqual     // - The method's return type is boolean     // - The method's first parameter is an int     // - The method's second parameter is an int     // - The method returns true if the two given ints are     //   equal, else false.  As a hint, you will need to use ==       // The second method has the following properties:     // - The method's name is areNotEqual     // - The method's return type is boolean     // - The method's first parameter is an int     // - The method's second parameter is an int     // - The method returns true if the two given ints are     //   NOT equal, else false.  As a hint, you will need to use !=           // DO NOT MODIFY main!     public static void main(String[] args) {         Scanner input = new Scanner(System.in);         System.out.print("Enter first integer: ");         int first = input.nextInt();         System.out.print("Enter second integer: ");         int second = input.nextInt();         System.out.println("Equal: " + areEqual(first, second));         System.out.println("Not equal: " + areNotEqual(first, second));     } }

Explanation / Answer

import java.util.Scanner;
public class IntEqual
{
public static boolean areEqual(int first, int second)
{
if(first == second)
return true;
else
return false;
}
public static boolean areNotEqual(int first, int second)
{
if(first != second)
return true;
else
return false;
}
  
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print(" Enter first integer: ");
int first = input.nextInt();
System.out.print(" Enter second integer: ");
int second = input.nextInt();
System.out.println(" Equal: " + areEqual(first, second));
System.out.println(" Not equal: " + areNotEqual(first, second));
}
}

OUTPUT


Enter first integer: 7
Enter second integer: 7
Equal: true

Not equal: false


Enter first integer: 7
Enter second integer: 8
Equal: false

Not equal: true