(java) Solved problem 48