#K34297. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
You are given a string representing a mathematical expression. The expression contains only non-negative integers and the operators +
(addition) and *
(multiplication). The multiplication operator has a higher precedence than addition.
Your task is to evaluate the expression and output the resulting integer. Note that the expression does not contain any parentheses and can be safely evaluated using the standard operator precedence.
Formula: \( result = \text{evaluation of the expression with } * \text{ having higher precedence than } + \)
inputFormat
The input consists of a single line containing a string that represents the mathematical expression. No extra spaces or parentheses are included in the expression.
Example:
2+3*4
outputFormat
Output a single integer which is the result of evaluating the given expression.
Example:
14
2+3
5