Code for problem 340A.