Initial functions based on example

Start with the logic of the example and rename variables for the new
functions.
Completed assignment 2

This is the final version for assignment 2.