I have followed the instructions in creating this quadratic program, but I keep getting these compiler errors: Error: cannot resolve symbol symbol : variable A location: class Quadratic Error: cannot resolve symbol symbol : variable B location: class Quadratic Error: cannot resolve symbol symbol : variable C location: class Quadratic here is the code:
The errors says line 50, which is the g.drawString( "Solving " +A ..... Please help.
Welcome to JavaRanch, Bob! The variable A declared in the main method is not available in another method. In other words, variables local to a method are not accessible from another method. Perhaps you want A to be an instance variable - declared outside of any method. Getting any ideas?
Hi Bob, Welcome to JavaRanch! The variables A, B, and C are defined inside the method main(). That means, by default, that they're only available inside main(). If you try to use them in paint(), as you do here, the compiler will complain that it doesn't know which A, B, and C you mean, since there are none that apply during paint(). There are a couple of ways to exchange information between methods. One way is by passing the variables as arguments -- just as you pass the string firstNumber to the Integer.parseInt() method, you could imaging passing A, B, and C to paint(). Unfortunately, in this case, paint() doesn't accept any int arguments, so that isn't going to work here. What you could do instead is make A, B, and C into static variables defined in the scope of the class itself, not inside main(). Such variables would be useable by all the methods in the class.