Exercise fromt the book The Art and Science of Java