Java code for EPI Problems