Implemented calculator logic.