Added solutions to Problem 6 in C++ & Java.