modified homework7.cc