Java Code from Homework