Added code for problems 4.2 and 4.3