I need to be able to handle a math equation such as "(45+9)/8" in my app. I wanted to just eval it using JavaScript, but realized that I can't use javax.script in Android. So, I found WebView, but I'm having a bit of trouble using it. Most of the examples refer to using an external page with the JS code, or using "javascript: var return ...etc." I'd need to use the latter, but I've been having a bit of trouble with returning the variable to my app.
Is it possible to have the JS eval it and then write the value to a hidden TextView?
Write equationsTap Home and select Insert. Under Insert, choose Insert New Equation. You get the prompt to type a new equation. After you type your equation in linear format, tap to see Math Options.
Although there is no direct way to show math formula in android TextView, But you can use MathJaxWebView and use the webview to show formula using it. Visit the link for more infomation on how to do it. Show activity on this post. *You can use MathJax also but it is slightly heavy.
Equatio allows you to create equations, formulas, and more, digitally. Helping to make math and STEM classes more accessible and engaging for every student. Try Equatio. Google Chrome. Web App.
Check out exp4j. It's a simple expression evaluator for java. For the equation you posted in your question you could just do:
Calculable calc = new ExpressionBuilder("(45+9)/8").build()
double result1=calc.calculate();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With