Solve problem 21 using Java.