Implemented and tested problem 8.