You are given two integers 'a' and 'b'. One per line in this order. Your goal is to compare these integers using the basic relational operators and print all results that are true. If 'a' is greater than 'b' print 'Greater'. If 'a' is less than 'b' print 'Less'. If 'a' equals 'b' print 'Equal'. Make sure to evaluate all these conditions for the given integers.
Comparing values. Relational operators
Comparing two integers with basic relational operators
Report a typo
Sample Input 1:
1
2Sample Output 1:
LessSample Input 2:
3
3Sample Output 2:
EqualWrite a program in Java 25
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// read the first integer
int a = scanner.nextInt();
// read the second integer
int b = scanner.nextInt();
// Perform the comparison of a and b
// compare if value of a is more than b
// compare if value of a is less than b
// compare if value of a equals b
}
}
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.