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'.
Comparing values. Relational operators
Comparing two integer inputs
Report a typo
Sample Input 1:
3
7Sample Output 1:
less thanSample Input 2:
5
5Sample Output 2:
equal toWrite 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
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.