#K37792. Evaluate Mathematical Expression

    ID: 26055 Type: Default 1000ms 256MiB

Evaluate Mathematical Expression

Evaluate Mathematical Expression

You are given a mathematical expression as a string. Your task is to evaluate the expression and print the result. The expression can include integers, the operators \( + \), \( - \), \( \times \) (represented by *), and \( \div \) (represented by /), as well as parentheses for grouping. Note that operator precedence is respected (i.e. \( * \) and \( / \) have higher precedence than \( + \) and \( - \)).

For example:

  • 3 + 5 should output 8.0
  • (3 + 5) * 2 should output 16.0
  • 3 + 4 * 2 / (1 - 5) should output 1.0

Your program must read input from stdin and write the result to stdout.

inputFormat

The input consists of a single line containing a valid mathematical expression. There are no extra characters.

outputFormat

Output a single floating point number which is the result of evaluating the expression.

## sample
3 + 5
8.0

</p>