Java Academic assignment