finished problem 3 in homework8.txt