Implement a calculator using a stack data structure