If you want to calculate something that does not take into account grouping operators (such as (
and )
) or follow the order of operations / operator precedence, this is a fairly straightforward.
If however you do want to take those things into account, then you have to be willing to write a parser for a context free language.
OR, you could search for a library out there that has already been written