Comparing two integer inputs

Report a typo

Write a java program that scans two integer inputs, compares them and prints if the first is less than, equal to or greater than the second one. For comparison use these statements 'less than', 'equal to' and 'greater than'.

Sample Input 1:

3
7

Sample Output 1:

less than

Sample Input 2:

5
5

Sample Output 2:

equal to
Write a program in Java 17
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

// Get the first integer from user input
int num1 = scanner.nextInt();

// Get the second integer from user input
int num2 = scanner.nextInt();

// Write your code here to compare num1 and num2
// You should use the relational operators to compare the values
// Then print 'less than', 'equal to' or 'greater than' according to the comparison result

}
}
___

Create a free account to access the full topic