Complete the code to print "Adult" if age is 18 or more.
int age = 20; if (age [1] 18) { System.out.println("Adult"); }
The condition age >= 18 checks if age is 18 or more, so it prints "Adult" correctly.
Complete the code to print "Even" if number is divisible by 2.
int number = 10; if (number [1] 2 == 0) { System.out.println("Even"); }
The modulus operator % gives the remainder. If number % 2 == 0, the number is even.
Fix the error in the condition to check if score is less than 50.
int score = 45; if (score [1] 50) { System.out.println("Fail"); }
The condition should be score < 50 to check if score is less than 50.
Fill both blanks to print "Teenager" if age is between 13 and 19 inclusive.
int age = 15; if (age [1] 13 && age [2] 19) { System.out.println("Teenager"); }
The condition age >= 13 && age <= 19 checks if age is between 13 and 19 inclusive.
Fill all three blanks to print "Eligible" if salary is above 3000, age is at least 18, and experience is more than 2 years.
int salary = 3500; int age = 25; int experience = 3; if (salary [1] 3000 && age [2] 18 && experience [3] 2) { System.out.println("Eligible"); }
The conditions are: salary > 3000, age >= 18, and experience > 2 to print "Eligible".