Solved problem 92 in Java.