finished code for quiz2 in chapter9!