Adding my homework written on Java