Question: Describe the scope error in the following program and explain how to fix it. public class Conversation { public static void main(String[] args) { Scanner
Describe the scope error in the following program and explain how to fix it.
public class Conversation
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("What is your first name? ");
String input = in.next();
System.out.println("Hello, " + input);
System.out.print("How old are you? ");
int input = in.nextInt();
input++;
System.out.println("Next year, you will be " + input);
}
}
Step by Step Solution
3.31 Rating (148 Votes )
There are 3 Steps involved in it
ANSWER The scope error in the following program is that the variable input is declared twice once as ... View full answer
Get step-by-step solutions from verified subject matter experts
