|
here is my assignment can anyone help me wid dis,i m so clueless abt dis
I have used all methods,but still not workin someone plzz help me
After you have learned about stack, how stack can be used to convert an infix expression into a postfix expression, and how a postfix expression can be evaluated, you would like to check how much you really understand what you have just learned.
Requirement Instead of buying a calculator, you now have an option to implement a program to perform simple arithmetic using +, -, *, and / in an infix expression. * and / have higher precedence over + and -, and two arithmetic operators of the same precedence will be evaluated from left to right. You are required to implement a table (or using other data structure that is efficient for this application) to represent the precedence of the 4 arithmetic operators supported. Parentheses can be used to specify the order of evaluation. To make the task simpler, all tokens in the expression are separated by blanks as shown below: 1 + 2 * 3 - 4 / 2 + 5 * 6 Note that each operand is not restricted to just single digit and it can be any value found within an int.
After evaluation, the program will print the result.
Sample input 1 1 + 2 * 3 - 4 / 2 + 5 * 6
Sample output 1 35
Sample input 2 ( 10 + 20 ) * 30 - 4000 / 20 + 50 * 60
Sample output 2 3700
|