diff --git a/homework/calculate/calculate.hpp b/homework/calculate/calculate.hpp index 7a933a25..8908346f 100644 --- a/homework/calculate/calculate.hpp +++ b/homework/calculate/calculate.hpp @@ -2,6 +2,30 @@ #include std::string calculate(const std::string& command, int first, int second) { - // TODO: Implement your solution here and return proper value - return ""; + int result = 0; + if (command == "add") { + result = first + second; + } + + else if (command == "subtract") { + result = first - second; + } + + else if (command == "multiply") { + result = first * second; + } + + else if (command == "divide") { + if (second == 0) { + return "Division by 0"; + } + + result = first / second; + } + + else { + return "Invalid data"; + } + + return std::to_string(result); }