C++ and Java homework