Gas.java - Added Java code for the pseudocode algorithm