Complete the code to check if a number is positive.
int number = 10; if (number [1] 0) { System.out.println("Positive number"); }
The condition number > 0 checks if the number is positive.
Complete the code to print "Even" if the number is even.
int num = 4; if (num % 2 [1] 0) { System.out.println("Even"); }
The condition num % 2 == 0 checks if the number is even.
Fix the error in the if statement condition to check if age is at least 18.
int age = 20; if (age [1] 18) { System.out.println("Adult"); }
The condition age >= 18 checks if age is 18 or older.
Fill both blanks to complete the if-else statement that prints if a number is positive or not.
int n = -5; if (n [1] 0) { System.out.println("Positive"); } else { System.out.println("[2]"); }
The condition n > 0 checks for positive numbers, else it prints "Negative".
Fill all three blanks to complete the if-else if-else statement that categorizes a score.
int score = 75; if (score [1] 90) { System.out.println("Grade A"); } else if (score [2] 75) { System.out.println("Grade B"); } else { System.out.println("[3]"); }
The first condition checks if score is 90 or above for Grade A. The second checks if score is 75 or above for Grade B. Otherwise, it prints Grade C.