Age Eligibility Checker

Report a typo

Complete a Java program that checks the eligibility of a user to access certain content by providing feedback that matches the conditions for each case.

Fill in the gaps with the relevant elements
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int requiredAge = 18;
        int parentalConsentAge = 16;
        int userAge = scanner.nextInt();

        String feedback = ;
        if (userAge < requiredAge) {
            if (userAge >= parentalConsentAge) {
                feedback = ;
            } else {
                int remainingYears = requiredAge - userAge;
                feedback = ;
            }
        }
        System.out.println(feedback);
    }
}
"You are eligible to access the content.""You need " + remainingYears + " more years to reach that age.""You need parental consent to access the content."

Create a free account to access the full topic