So I'm making this program...

I've been messing around with making an advanced calculator in Java by implementing popular algorithm solving techniques like PEMDAS and SABDM (Both commonly used for Algebra and other equations) and I was wondering, what be the best way to go about doing this?

Right now, I've implemented PEMDAS, and the first thing it does is search for parenthesis and then cuts what's inside and places them in Arrays. So, you type in:

(1+1)

and it cuts out and prints:

1+1

So, then it has to calculate it, but I don't know where to start. I can't just be like you know:

a = bgc

Where a is the answer, b is the first number, g is the solving type, and c is the other number.

So what should I do?

Re: So I'm making this program...

When attempting this sort of program it generally helps if you convert the infix expression (1 + 2) to a postfix expression (1 2 +). If you do this correctly then you can incorporate brackets as well. Then to evaluate the postfix expression it is achieved by using a Stack. When you get to an operand push it onto the Stack. When you get to an operator you pop 2 values of the Stack, apply the operator and push the result back onto the Stack. At the end the only value left on the Stack will be the final result.

Re: So I'm making this program...

I like your ideas, but do you think the postfix expression would be more of a hassle than anything?

Anyway, I finished the bracket cutting, it cuts out pieces in brackets and puts them in a List called "Parts"

I just gotta make Java cut the brackets from the main equation and replace them with the answers to the bracketed problems possibly, then turn that final equation string into an expression that can be calculated like I will with that actual bracketed strings.