converting a string of declared variables (e.g. "x+y") to a double as a mathematical function
<p>What I'm trying to do is read a line (string) and use it as a mathematical function to get (double) values or answers to it at different points (like a calculator basically)</p>

<p>I included a very simplistic code of what I'm trying to do just for the sake of being direct and straight forward:</p>

<pre><code>double x, y, z;
String function;

x = 5;
y = 4;
function = "(x*y)+y";

z = Double.parseDouble(function);

/*
I want z to equal this
z = (x*y)+y;
*/
System.out.print("z= " + z);
</code></pre>

<p>Again, this is only a sample code to be clearer about my question. My question again is: how can I set z = function when z is a double and function is a string?</p>

<p>NOTE: I tried parse as you can see, but it didn't work. I also tried to read the string character by character, but it didn't work either because it added the value of the characters together.</p>
