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?

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 int won't give you the correct result.

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 int won't give you the correct result.

using this i am getting the result but now i am having one problem:
The result is calculated in linear fashion instead i want it to follow BODMAS rule while
computing the value.
For eg my string is=221+33*123+3
so the code does this:
221+33=254
254*123=31242
31242+3=31245
So the result is 31245
now if i have to follow bodmas it should be:
33*123=4059
and then it should add 221 and 3,so the result would be 4283.
So how should i achieve this?

hi
this is one of my assignment that I have to do. it is a triangle calculator. everything well with it but it just the calculation. when I run it, ...

Good man James helped me learn die roll board game programming in Java,
and I applied it on Ladders and Snakes. Made one in Java. Now I'm learning to do ...