Exercise 14 from page 172 Thinking in Java