Chapter 2 homework (2nd attempt)