Are the first use of 'scanner' and the second use of 'scanner' the same variable, or are they in different scopes. If they are in different scopes , would it be better to use a different variable, for the code to be more readable?
Different variable in a different scope referring to the same thing. Normally I'd agree with giving it a different name, but both scanner variables refer to the same object in memory, so it doesn't actually matter that they are different variables in the code as shown.