Menu
×
×
Correct!
Exercise:Follow the comments to insert the missing parts of the code below:
// Create a checkAge() method with an integer variable called age
static void checkAge(int age) {
// If age is less than 18, print "Access denied"
if (age < 18) {
System.out.println("Access denied");
// If age is greater than 18, print "Access granted"
} else {
System.out.println("Access granted");
}
}
public static void main(String[] args) {
// Call the checkAge method and pass along an age of 20
checkAge(20);
}
Not CorrectClick here to try again. Correct!Next ❯// Create a checkAge() method with an integer variable called age static void ( ) { // If age is less than 18, print "Access denied" ( ) { System.out.println("Access denied"); // If age is greater than 18, print "Access granted" } { System.out.println("Access granted"); } } public static void main(String[] args) { // Call the checkAge method and pass along an age of 20 ( ); } |