User input math

Hi there.
Let's say one would have the user input a couple of variables, x and y. After that, the user will input a function, you know, with the usual y = 2 + 3x, or whatever.
Would it need a lot of work/expertise to have the program calculate the outcome for you? I find it very hard to see through, although I am new to c++...
I just figured, since the variables of the equuation is already known, it's kind of basic math (addition, multiplied etc.), so I assumed it wouldn't be too advanced. Am I wrong?

I'm not looking for someone to program the code or anything. If you guys would be so kind as to point me to some usefull material, it would be greatly appreciated!
Your equation "2 + 3x" has actually three terms and two binary operators: "2 + 3 * x". Parsing from your syntax to my syntax is an additional step. Then you have to determine the precedence of operators, i.e. that "2+3*x" is same as "2+(3*x)" and not same as "(2+3)*x".

Parsing the equation should create a tree of objects. Then the tree/equation can be evaluated with proper traversal.

Relatively simple exercise.
Oh, I'm aware that its 2 + (3*x), I guess it's just an old habbit from math class.

However, I think we've misunderstood each other (Given english is not my native tongue, it might be on my end though). It's not the specific equation "y = 2 + (3*x)" that I want it to solve. I want it to solve any kind of equations, with basic binary operators. Let me give you an example:

User inputs the value of x:
x=3
User goes on to input the equation:
y = 4 + (12*x) + (2*x)
(since x is equal to 3, the equation will of course be: y = 4+36+6.
y is in this case just a variable I put in to make it seem more simple. I'm not interested in the program defining the variable y as 46, but only to figure out that the equations equals 46)

Now, I just want the program to solve the equation on it's own, since the program has to be able to adapt to any kind of basic equation, that the user has typed.

Putting it like that, actually made the whole thing seem much more complicated than at first... Perhaps it's out of my league after all.

I hope I haven't misinterpered your reply, since it would make this reply seem rather silly. Bear with me please!
Topic archived. No new replies allowed.