Done with problem 3 in java