#K43407. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
You are given a mathematical expression represented as a string. The expression contains only non-negative integers and the operators +, -, *, and /. The tokens in the expression are separated by spaces. Your task is to evaluate the expression and output the result as an integer.
The expression should be evaluated by following the standard operator precedence rules:
\( \text{Multiplication and Division are evaluated before Addition and Subtraction.} \)
For example, given the expression "3 + 5", the result is \(8\). For "10 - 2 * 3", the multiplication is performed first yielding \(10 - 6 = 4\).
Please note that for division, use integer division which truncates toward zero.
inputFormat
The input consists of a single line containing the mathematical expression.
Example: 15 - 4 + 2 * 3
outputFormat
Output the result of the evaluated expression as an integer.
Example: 17
## sample3 + 5
8