Complete the code to check if the number is positive.
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 number" if the number is even.
if (number [1] 2 == 0) { System.out.println("Even number"); }
The modulus operator % gives the remainder. If number % 2 == 0, the number is even.
Fix the error in the if statement condition to check if age is at least 18.
if (age [1] 18) { System.out.println("Adult"); }
The condition age >= 18 checks if age is 18 or older.
Fill both blanks to check if a number is between 10 and 20 (inclusive).
if (number [1] 10 && number [2] 20) { System.out.println("Number is between 10 and 20"); }
The condition number >= 10 && number <= 20 checks if the number is between 10 and 20 including both ends.
Fill all three blanks to print the grade based on score: A if score >= 90, B if score >= 80, else C.
if (score [1] 90) { System.out.println("Grade A"); } else if (score [2] 80) { System.out.println("Grade B"); } else { System.out.println("Grade [3]"); }
The first condition checks if score is 90 or more for grade A. The second checks if score is 80 or more for grade B. Otherwise, grade C is printed.