EvalExpr is an useful class that evaluates an expression held in a string and returns the result. The license is Lesser GPL so you can use the class in your own projects. Additionaly, a free sample calculator is given with the class, a demo version is available on the project page.