import java.lang.Math;
public class Evaluate {
public static void main(String...args) {
Stack<String> ops = new Stack<>();
Stack<Double> vals = new Stack<>();
String exp = "( ( 1 + 5 ) / ( sqrt 10 ) )";
String[] ss = exp.split(" ");
for(String s : ss) {
if(s.equals("(");
else if(s.equals("+") || s.equals("-") || s.equals("*") || s.equals("/") || s.equals("sqrt")) ops.push(s);
else if(s.equals(")") {
String op = ops.pop();
Double v = vals.pop();
if(op.equals("+") v = vals.pop() + v;
else if(op.equals("-") v = vals.pop() - v;
else if(op.equals("*") v= vals.pop() * v;
else if(op.equals("/") v = vals.pop() / v;
else if(op.equals("sqrt") v = Math.sqrt(v);
//what is missing here?
} else {
vals.push(Double.parseDouble(s));
}
}
System.out.println(exp + "=" + vals.pop());
}
}