I have the folowing code, but there is a compiling error of:
MathProblemRevised.java:25: error: cannot find symbol
if (inputCharacter.equals("Y")) {
^
symbol: variable inputCharacter
location: class MathProblemRevised
1 error
With the code:
import static java.lang.System.*;
import java.util.Scanner;
class MathProblemRevised {
public static void main(String args[]) {
Scanner keybardInput = new Scanner(System.in);
Scanner keybardInput2 = new Scanner(System.in);
System.out.println(" What is 5 + 12?");
System.out.print(" ");
double inputNumber = keybardInput.nextDouble();
System.out.println();
if (inputNumber == 17){
System.out.println(" You are correct!");
}
if (inputNumber != 17){
System.out.println(" You are incorrect!");
System.out.println(" Do you want to give it another try? Y/N");
//String inputCharacter;
System.out.print(" ");
String inputCharacter = keybardInput2.next();
}
if (inputCharacter.equals("Y")) {
String inputCharacter = keybardInput2.next();
} else {
out.println(" Thanks for taking your time!");
}
}
}
How wold I fix this problem?