Wrote code (along with a test) for Exercise 1 at the end of Chapter 2