c++ first year homework 8