Full, working homework.cpp