[Solved] Java – How to write a code that Solve equation inside a String? [closed]


Well. I cannot give you code… I can give you some advice..

  1. Split the String based on semicolon (;).
  2. For each String in the array (which you got after splitting, except the last one) split it again based on “=”.
  3. Take the RHS of the split String and parse it as integer.
  4. Now parse the last String which you got after splitting the main String based on “;”. See what operation is present inside it using contains(). Also check what are the variables involved using contains(). Check the variables int value (which you got after splitting based on “=” and using Integer.parseInt on the RHS part.)
  5. Perform the operation based on what the String contains (*,+,-,/) . You could use a switch statement for this.

1

solved Java – How to write a code that Solve equation inside a String? [closed]