solve parts 4 and 5 of assignment 5