Hey, I have 2 problems if anyone can offer help i'd really appreciate it!
First problem I have is with my try and catch. Its hard to explain (I don't know whats wrong with it)
My second problem is with the bottom section where I ask do you want to check ten more? I want to return to the question when the else is triggered. I don't even know if this is possible.
Thanks for looking!
import java.util.Scanner; class testcatch { public static void main ( String []args ) { int number = 1; String a = ""; int age = 0; int count = 1; Scanner userin = new Scanner(System.in); Scanner scan2 = new Scanner(System.in); while (count <= 10) { try { System.out.println(+number+". Please enter your age:"); age = userin.nextInt(); ++number; if (age == 4) { System.out.println(""); System.out.println("Your age is "+age+". Your still young!."); System.out.println(""); } else if (age == 5) { System.out.println(""); System.out.println("Your age is "+age+". You getting old!."); System.out.println(""); } else if (age == 6) { System.out.println(""); System.out.println("Your age is "+age+". You getting older!."); System.out.println(""); } else { System.out.println(""); System.out.println("ONLY AGES 4 - 5 AND 6"); System.out.println(""); System.out.println(""); --count; --number; } } catch (Exception e) { System.out.println(""); System.out.println("ONLY AGES 4 - 5 AND 6"); System.out.println(""); System.out.println(""); --count; --number; } if (count == 10) { System.out.println("Do you want to check ten more ages?"); a = scan2.nextLine(); if (a.equalsIgnoreCase("yes") || a.equalsIgnoreCase("y")) { System.out.println(""); System.out.println(""); count=0; number = 1; } else if (a.equalsIgnoreCase("No") || a.equalsIgnoreCase("n")) { System.out.println(""); System.out.println(""); System.out.println("Bye Bye!"); System.out.println(""); System.exit(0); } else { // How to return to yes or no question? } } {count++;} } } }