This library uses String parsing to be able to take in an
equation such as 8 + 2
to give you 10
.
import jkowski.arithmocha.Expression;
public class ExpressionTests {
public static void main(String[] args) {
System.out.println(
Expression.evaluate("10 + 2 + 7 * 15")
); // 117.0
System.out.println(
Expression.evaluate("10 * (5 + 5) - (4 + 1)")
); // 95.0
System.out.println(
Expression.evaluate("5 + (4 + (3 + (2 + 1)))")
); // 15.0
}
}
This will evaluate and return the result of the expression.
Some things to work on
- Simple expression evaluation
- Nested expression evaluation
- Function definitions
- Functions with variables
- Functions with multiple variables
-
Functions inside expressions(Not sure if this is in scope, may come back later) - sqrt and other common functions