So here is something i am trying to do:
1.Store a mathematical expression eg. 23*32+12 in the String datatype.
2.Now i have to calculate the value of that expression.
So i thought of converting the string to integer using parseInt , but for this the string need not contain *,+ and other operators.So how can i calculate the value of that expression?
Jump to Post
with the indexOf method, you'll be able to detect where there are mathematical symbols, such as * + /
next, use the substring method, to divide the String you have, and run the Integer.parseInt method on the substrings you've found.
but make sure you only have non-decimal numbers, otherwise, an …