#K37792. Evaluate Mathematical Expression
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 output8.0
(3 + 5) * 2
should output16.0
3 + 4 * 2 / (1 - 5)
should output1.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.
## sample3 + 5
8.0
</p>