0

In Eclipse, I am trying to evaluate a mathematical expression in a string. Example:

String ex="12+35-8+32"

How can I obtain and integer with value = 71? In one previous such similar question I got reference of NCalc. I downloaded it (which came with a Sources folder and a .dll file) but could not figure out how to use it. Thank you so much!

  • 2
    possible duplicate of [Evaluating a math expression given in string form](http://stackoverflow.com/questions/3422673/evaluating-a-math-expression-given-in-string-form) – rlegendi Jun 10 '14 at 12:23
  • I cheked that but that did not help my case :/ – Bodhisatwa Jun 10 '14 at 13:44
  • So why not? :-) Can't you simply replace the "40+2" with your expression (or even going further: make a function that evaluates a specific String)? What have you tried? – rlegendi Jun 10 '14 at 15:18
  • I am working on eclipse. The imports aren't working. – Bodhisatwa Jun 10 '14 at 16:24
  • On JDK 1.6+, the solution with `ScriptEngineManager` should work without hassle. Just press Ctrl+Shift+O... Or you should set up the classpath required to run your code (i.e., download the libs and add them to your build path). – rlegendi Jun 10 '14 at 18:49
  • https://github.com/uklimaschewski/EvalEx – miracle-doh Mar 23 '16 at 20:26

0 Answers0