// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import javax.script.ScriptEngineManager;
import javax.script.ScriptEngine;

public class Eval {
    public static void main(String[] args) throws Exception {
        ScriptEngineManager mgr = new ScriptEngineManager();
        ScriptEngine js = mgr.getEngineByName("js");
        System.out.println(js.eval("Math.cos(Math.PI/4)"));
        System.out.println(js.eval("Math.pow(Math.cos(Math.PI), 2)"));
    }
}
