public static void add2q() {
    System.out.print("Age:");
    age = sc.nextInt();
    if (!(age >= 3 && age <= 80)) {
        System.out.println("Sorry you must be between the age of 3 to 80");
    } else if (age >= 3 && age <= 5) {
        while (true) {
            System.out.println("Need to be accompanied by an adult above 16\nHave an adult to accompany?y/n");
            String yn = sc.nextLine();
            if (yn.equals("y")) {
                System.out.print("Child's Name: ");
                name = sc.nextLine();
                names.add(name);
                price();
                addAdult();
                break;
            } else if (yn.equals("n")) {
                while (true) {
                    System.out.println("Sorry you cannot take this ride");
                    add2q();
                    break;
                }
            } else {
                System.out.println("Invalid output"); //funny problem here 
            }
        }
    } else {
        System.out.print("Name: ");
        name = sc.nextLine();
        names.add(name);
        price();
    }
}
When user types in 3 or 4 or 5, it will print the "need to be..." as well as the "Invalid output statement", but I don't want the last statement. How can I prevent the last statement from being shown?
 
     
     
    