Completed problem 4 in Java
Completed problem 6 in Java