static int eval(String infix) {
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
String stringResult;
try {
stringResult = engine.eval(infix).toString();
double doubleResult = Double.parseDouble(stringResult);
int result = (int) doubleResult;
return result;
} catch (ScriptException ex) {
Logger.getLogger(Ukol4a.class.getName()).log(Level.SEVERE, null, ex);
}
return(1);
}