×
×
Correct!
Follow the comments to insert the missing parts of the code below:
// Create a checkAge() method with an integer variable called age
static void @(8)(@(3) @(3)) {
// If age is less than 18, print "Access denied"
@(2) (@(3) @(1) @(2)) {
System.out.println("Access denied");
// If age is greater than, or equal to, 18, print "Access granted"
} @(4) {
System.out.println("Access granted");
}
}
public static void main(String[] args) {
// Call the checkAge method and pass along an age of 20
@(8)(@(2));
}
// 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, or equal to, 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! |
This will reset the score of ALL 59 exercises.
Are you sure you want to continue?