Everything else is working in both programs but every time I try to compile and run it gives me this error Duplicate local variable input and I can not seem to fix it. I've looked up solutions none seem to work.
**Scanner scan = new Scanner(System.in); **//Duplicate****
System.out.println("What is the capital of Canada?");
String input = scan.nextLine();
if (input.equalsIgnoreCase("Ottawa")) {
System.out.println("Correct");
} else {
System.out.println("incorrect");
}
Seperate Program
I have tested this code out on a test run and everything runs smoothly when it is not joined with the code posted ahead of this one and I need it for an assignment due tonight.
**Scanner input = new Scanner(System.in); //This is the error. Also Duplicate.**
int num1;
int num2;
int num3;
int sum;
System.out.println("Enter first integer:");
num1 = input.nextInt();
System.out.println("Enter second integer:");
num2 = input.nextInt();
System.out.println("Enter third integer:");
num3 = input.nextInt();
sum = num1 + num2 + num3;
if (num1 > num2 & num2 > num3) {
System.out.println("The number is");
System.out.println(sum);
}