How to take in code from user?

2019-09-05 22:32发布

问题:

See I want to do this Equation Graph Plotter in Java using Netbeans. I am using Graphics 2D to plot the idividual Points. My Question is is it possible to take in an equation from the user and put it in the code ??

Example : float y=(float) ( Math.sin(x/100)*100);

Suppose the user wants to see a cos graph is it possible to type in Math.cos(x/100)*100 and equate it to y ?

If not how do I solve this ?? Any Alternate methods Appreciated