Problem1 finished in java8
prob 1, 2 java