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