Get the String:

String equation = user input;

Separate the string into a String list(array? arrayList?) of components.

example

equation = x^7+13x^4-22

your string array looks like

string1 = x^7

string2 = +

string3 = 13x^4 (not sure if you need 13(x^4) to be specific

string4 = -

string5 = 22

remember multiplication and division are commutative.

addition and subtraction, also commutative.

on a side note ^ (shift6) is used to show something raised to the power of. x^2 is x squared 3^3 is 27

thus, to be a stickler what you want is:

5(x^2)+3x-8

once you have the equation broken into logical usable parts what you do with it is all mathematical logic. I would suggest recursion but it would probably only add a layer of complication if you are not good with recursive coding.

but if you find you have just an x value and a constant, then you can solve by isolating x. if you have an x^2 and an x and a constant to can solve using standard binomial methods. Write methods to solve the equation based on what type it is.