Created the solution to Problem 6 in C++.