Write a program that is able to perform 5 operations:
addition +
,
subtraction -
,
multiplication *
,
division /
or
exponentiation ^
.
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
1 + 2
3.5 * 6
7 - 12
20 / 3
-10 ^ 3
3.00
21.00
-5.00
6.67
-1000.00
In this exercise, exponents may have decimal places.
try first: bmi
try next: factorial
Copyright © 2020-2022 Rudy Matela
This text is available under the CC BY-SA 4.0 license.
Originally available on cscx.org/calc