write the code of chap06