/** Demo on 23 September. Static methods */
public class Demo {
    
    /** Precondition: s contains at least one integer (without sign), and they are
    //  separated by commas (blanks are permissible after a comma). There are
    //  no blanks at the beginning and end of s.
    //  = s but with its first integer removed (remove also following
    //  comma,
    //  if there is one, and following blanks).
    //  E.g.  s = "52,       0, 76385"        Return "0, 76385" 
    //        s = "000,      11"              Return "11"
    //        s = "00"                        Return ""
    //  */
    public static String removeInt(String s) {
        // Store in k the position following the first integer
        int k;
        k= s.indexOf(',');
        if (k == -1) {
            k= s.length();
        }
        
        // Remove first integer from s
        s=  s.substring(k);
        if (s.length() != 0) {
            // Remove comma and beginning blanks from s
            s= s.substring(1);
            s= s.trim();
        }
        return s;
    }
    
    // NOTE: The following method body uses function Integer.valueOf(String),
    // which we really haven't discussed yet.
    
    // The important point in the function below is to make use of a function
    // that is already written, rather than duplicate work
    
    /** Precondition: s contains at least one integer
      * (without sign),
      * and they are separated by commas (blanks are
      * permissible after a comma). There are
      no blanks at the beginning and end of s.
      If the first integer is 0, return s but with its
      first integer and following Ô,Õ   
      and blanks removed; otherwise, return s.
      E.g.  s = "52,       0, 76385"        Return s,
            s = "000,      11"              Change s to "11".
            s = "00"                        Change s to "".*/
    public static String removeZero(String s) {
        // Store in k the position following the first integer
        int k;
        k= s.indexOf(',');
        if (k == -1) {
            k= s.length();
        }
        
        String first= s.substring(0,k);
        if (Integer.valueOf(first) == 0) {
            return removeInt(s);
        } else {
            return s;
        }
        
    }

    
}