Completed HW1Q4.cpp