(java) Solved problem 15