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