Created the solution to Problem 1 in Java.