part 4 of programming assignment completed using only standard libraries