Write a program that takes an integer as input. If the integer is positive, print 'Positive'. If the integer is negative, print 'Negative'. If the integer is zero, print 'Zero'.
One-line condition with ternary operator
Categorize integer as positive, negative, or zero
Report a typo
Sample Input 1:
5Sample Output 1:
PositiveSample Input 2:
-3Sample Output 2:
NegativeWrite a program in Java 17
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Read the integer input
int num = scanner.nextInt();
// Use a ternary operator to check if the integer is positive, negative or zero
// and print the corresponding message
}
}
___
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.