#K37287. Arithmetic Expression Evaluator

    ID: 25943 Type: Default 1000ms 256MiB

Arithmetic Expression Evaluator

Arithmetic Expression Evaluator

In this problem, you are given several arithmetic expressions, one per line, on standard input. Your task is to evaluate each expression and output the result rounded to two decimal places. Each expression may contain non-negative numbers, the operators +, -, *, /, and parentheses. Any line that is empty or contains only whitespace should be ignored.

The evaluation should follow the normal operator precedence: multiplication and division have higher precedence than addition and subtraction. Parentheses can be used to override the standard precedence. Results should be printed on separate lines exactly in the order of input.

For example, given the following input:

5+3*2
4/2-1
7*(3+2)
9/3*3+2
2+(3-1*2)/4

The correct output is:

11.00
1.00
35.00
11.00
2.25

Note: If any expression is invalid, you may assume that the input will be valid for this problem.

inputFormat

The input is given through standard input (stdin). It consists of multiple lines; each non-empty line contains an arithmetic expression to be evaluated. Empty lines or lines containing only whitespace should be ignored.

outputFormat

For each non-empty input line, output the evaluated result rounded to two decimal places. Each result should be printed on its own line and the output should be written to standard output (stdout).## sample

5+3*2
4/2-1
7*(3+2)
9/3*3+2
2+(3-1*2)/4
11.00

1.00 35.00 11.00 2.25

</p>