finished code for quiz 2 in chapter7!