index | submit | rank | book

calc – 5-operation Calculator

Write a program that is able to perform 5 operations: addition +, subtraction -, multiplication *, division / or exponentiation ^.

Input and output

Input consists of several lines, each with a number x, a character o and another number y separated by spaces where

-2 000 000.00 ≤ x, y ≤ 2 000 000.00

o is +, -, *, / or ^

Output should contain a single line with the corresponding result of applying operator o to x and y. Output should be rounded to two decimal places.

Inputs are given so that the resulting value r is within the following range:

-2 000 000.00 ≤ r ≤ 2 000 000.00

Example input

1 + 2
3.5 * 6
7 - 12
20 / 3
-10 ^ 3

Example output

3.00
21.00
-5.00
6.67
-1000.00

Scoring

Hints

In this exercise, exponents may have decimal places.

try first: bmi

try next: factorial

index | submit | rank | book

Copyright © 2020-2021 Rudy Matela
All rights reserved