Chap3 sample codes