Solved Problem6 in java