Completed programming exercise of chapter 2