finished code for quiz1 in chapter9