C++ code for Stanford CS106b assignment 3