I keep getting errors from the compiler saying it can't find the symbols a,b and c in this class. Unless I'm blind, I think I clearly defined them in the first part of the code.
public class Algebra { public void linearAlg() { System.out.println("Enter variables a b and c in ax+b=c"); try { CalcInput user = new CalcInput(); String userInput = user.getUserInput(" "); double a = Double.parseDouble(userInput); String userInput2 = user.getUserInput(" "); double b = Double.parseDouble(userInput2); String userInput3 = user.getUserInput(" "); double c = Double.parseDouble(userInput3); } catch(NumberFormatException e) { System.out.println("Your input was invalid. Only numeric real entries are accepted."); System.out.println("Do not use operators. Enter the a,b and c variables in ax+b=c"); System.out.println(""); } catch(NullPointerException e) { System.out.println("There must be an input!"); System.out.println(""); } if(b < 0) { AlgebraHelper helper = new AlgebraHelper(); helper.setVars(b,c); double addNum = helper.addThis(); helper.setVars(addNum,c); double divNum = helper.divThis(); System.out.println(divNum); } else if(b == 0) { AlgebraHelper helper = new AlgebraHelper(); helper.setVars(a,c); double divNum = helper.divThis(); System.out.println(divNum); } else { AlgebraHelper helper = new AlgebraHelper(); helper.setVars(b,c); double subNum = helper.subThis(); helper.setVars(subNum,c); double divNum = helper.divThis(); System.out.println(divNum); } } }
Is it because the a,b,c variables are being used inside of a loop?
If that is the case, how do I get the previously defined symbols to be recognized in the loop?