completed solution to programming assignment 3