problem 14 java code