Hi, I attached my solution about yours problems, I comment diferents parts about code. There are two functions where a signal if is a numérica data or category of age. &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
import java.util.Scanner; public class main { public static void main(String[] args) { System.out.print("Type your age: "); Scanner sc = new Scanner(System.in); //Save var String String ageStr = sc.nextLine(); String notify="Not an age."; //Evaluate the age if we typify a number. if (isNumeric(ageStr)==true) { int age = Integer.parseInt(ageStr); notify = myAge(age); } //Notification about your Age System.out.println(notify); } //Method about Age public static String myAge(int age) { if (age >= 18) { return "Over 18 or equals 18"; } else if (age == 0) { return "0 age?"; } else if (age <= 18) { return "Under 18"; } return null; } //Method is numeric? public static boolean isNumeric(final String str) { if (str == null || str.length() == 0) { return false; } for (char c : str.toCharArray()) { if (!Character.isDigit(c)) { return false; } } return true; }
}
I hope that can I help you
Regards