This question is not language-specific. I've written run-time equation evaluators in C before, and basically what you have to do is convert infix to postfix (aka "reverse Polish" notation), then execute the postfix. You can find easy algorithms online to do both these things. Postfix expressions are evaluated using a stack, and it is very easy to write code to do this.