Question: Below is the java code to solve an equation, the only thing I want in it is to ask the user to enter input and
Below is the java code to solve an equation, the only thing I want in it is to ask the user to enter input and then the program will solve the equation. Thanks.
THE CODE IS BELOW......
import java.util.Stack;
public class Equation { public static void main(String[] args) { String expression = "(2+3)*(8-4)*(5-3)"; int output = evaluate(expression); System.out.println("Expression: "+expression); System.out.println("Output: "+output); } public static int evaluate(String expression) { char[] tempTokens = expression.toCharArray(); char[] tokens = new char[tempTokens.length*2]; int count = 0; for (int i=0;i Stack Stack
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
