import java.util.*; public class ScopeError { public static void main( String args[]) { double usersDouble = 0.0; //When I declare variables at the top of the method, I do not get scope errors int usersInteger = 0; Scanner console = new Scanner (System.in); System.out.print("Input an integer or a double: "); if ( console.hasNextInt() ) { //int usersInteger = console.nextInt(); //if I declared the variable inside this code block, I will get a scope error usersInteger = console.nextInt(); } else if ( console.hasNextDouble() ) { //double usertsDouble = console.nextDouble(); // if I declared the variable inside this code block I will get a scope error usersDouble = console.nextDouble(); } else { System.out.print("\nThat was not either an integer nor a double"); System.exit(1); } System.out.println("your double: " + usersDouble); } }