Calculate a funktion entered as a string.

Andi03

Freshman
Joined
Sep 5, 2003
Messages
43
Hi.
If I enter a function into a textbox, for example f(x) = 3x+1 where the 3x+1 is the part entered into the text box. How can I from that calculate the values for x = 2, x = 3 and so on so I can stor the values in array.

Im making a application that will plot the function intp a graph so I need to calculate som of the values the function will return so I can plot it.

If im not clear in my text respond and I'll try to explain more. Thanks for any help that will be given to me.

//A
 
You'll need to parse the entered formula and then apply values to the variables detected. Don't forget your order of operations! If you search around the web, you might be able to find someone who has done this already and you can leverage their code or at least get some ideas.

You will probably find a stack structure useful for determining order of operations as you parse.
 
Thanks! I will look in to it. I want to try it befor looking at others work. I will now been googleing parse formula and look up stacking in my old programming book.
 
Back
Top