Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
there are third-party libraries, e.g. mXparser https://en.wikipedia.org/wiki/Mxparser#User-defined_functions[3] http://mathparser.org/api/org/mariuszgromada/math/mxparser/Function.html Function f = new Function("f(x, y) = sin(x)+cos(y)"); Expression e = new Expression("f(1,2)", f); double v = e.calculate();
20th Feb 2020, 1:35 AM
zemiak
0
There are no predefined functions in java to do what you are asking for. You have to write the code but it will be specific for a single equation. For eg- Like you showed. There can be three operands, each separated by an operator. It could be any legal operator and the input should be a string type.
19th Feb 2020, 3:55 PM
Avinesh
Avinesh - avatar