Given a number, write a program in Java to determine whether this number is equal to 10 or not. Your program should take a single integer as input and print "Equal" if the number is 10, or "Not Equal" otherwise.
One-line condition with ternary operator
Check if a given number is equal to 10
Report a typo
Sample Input 1:
10Sample Output 1:
EqualSample Input 2:
20Sample Output 2:
Not EqualWrite a program in Java 25
import java.util.Scanner; // Required to read user input
public class Main {
public static void main(String[] args) {
// Create a Scanner object to read input
Scanner scanner = new Scanner(System.in);
// Read input
int num = scanner.nextInt();
// Put your code with ternary operator here
}
}
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.