#C10341. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
You are given a string representing a mathematical expression that uses the keywords times
and divided
to denote multiplication and division respectively. Your task is to evaluate the expression and output the result as a string. For example, the expression 12divided2times3 should be interpreted as \(12 \div 2 \times 3\) and its result is 18.0.
Note:
- All numbers in the expression are non-negative and can be integers or decimals.
- The operations
times
anddivided
have the same precedence and are evaluated from left to right. - You must read the expression from standard input and print the output to standard output.
inputFormat
The input consists of a single line containing a non-empty string s
that represents the mathematical expression. The expression is formed by non-negative numbers and the keywords times
(for multiplication) and divided
(for division) without any spaces.
outputFormat
Output a single line containing the result of the evaluated expression. If the result is obtained by division, it should be printed as a floating point number.
## sample3times4times2
24