Website Summary Files Commits Branches @commit @diff @stats
path: root / Week04 / Exercise05.cpp
blob: 815a75132ada31b68eda9bc10c3c0d7c0145a705 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>

int main() {
    char operation;
    std::cin >> operation;

    if (operation == '_') {
        float number;
        std::cin >> number;
        std::cout << (int)number;
    }
    else if (operation == '+') {
        float a, b;
        std::cin >> a >> b;
        std::cout << (a + b);
    }
    else if (operation == '*') {
        float a, b;
        std::cin >> a >> b;
        std::cout << (a * b);
    }
    else if (operation == 'x') {
        float a, b, c;
        std::cin >> a >> b >> c;
        std::cout << (a * b * c);
    }
    else if (operation == '.') {
        float a, b, c, d;
        std::cin >> a >> b >> c >> d;
        std::cout << (a * b * c * d);
    }

    return 0;
}