Java chapter 9 exercise 9. The solutions for Liang, Y.