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