Completed code for problem 9 and altered code for problem 6 slightly.