2

I have been creating a method for handling math expressions which are scientific. I came across the script engine and decided to use that. It must return the answer as a string. However, I keep getting the following error:

Error: unreported exception ScriptException; must be caught or declared to be throwing in Java

public String calculation(String val){
 ScriptEngineManager manager = new      ScriptEngineManager();
  ScriptEngine engine = manager.getEngineByName("js");
  Object result = engine.eval(val);
 String result1 = String.valueOf(result);
 return result1;
 }

Any help would be appreciated, thank you.

0 Answers0