#K94292. Evaluating Mathematical Expressions

    ID: 38609 Type: Default 1000ms 256MiB

Evaluating Mathematical Expressions

Evaluating Mathematical Expressions

You are given an arithmetic expression as a string. The expression can include positive integers, the binary operators +, -, *, /, and parentheses ( ). Each token in the expression is separated by a space.

Your task is to evaluate the expression while observing the standard operator precedence rules:

  • Multiplication and Division have higher precedence than Addition and Subtraction.
  • Parentheses ( ) override the usual precedence.

For division operations, always output a floating-point result. The expected computed answer should be printed as a floating-point number.

For example, the expression 100 * ( 2 + 12 ) / 14 should evaluate to $$100.0$$.

inputFormat

The input consists of a single line containing the arithmetic expression. All tokens (numbers, operators, and parentheses) are separated by spaces.

outputFormat

Print a single floating-point number — the result of evaluating the given expression.

## sample
3 + 5
8.0