problems 18 & 67 in java (they are the same)