Final code for Lab 6.10