For my algebra project I am making a java program that can graph an equation you type in. I got free basic graphing code from a website, and implemented a couple things. In the code, when it returns the equation for the graph, it is a double. In the code, you can change the equation in the double and it will graph it fine. When I try to put my string in the code(from user input) the program will crash if i put anything like X or * or / in the equation. I tried to put (Double.parseDouble(equation)) in the double, but it still doesn't work. BTW i am new at java. Thanks!
This is what the code looks like(class "circle1"):
public double getY(double x) {
return (Double.parseDouble(equation));
}
In the class that reads the equation, here is the code:
graph.functions.add(new Circle1());
(equation is the string)