Added the codes for exercise 7.4