Java code for the course cs602