Code for Program 6 finished