import java.util.*;

public class MoreLoops {
  
  /**
   * Display each word in the sentence s 
   * on a different line.
   */ 
  public static void printWords(String s) {
    
    // This constructor uses the default
    // set of delimiters: " \t\n\r\f"
    StringTokenizer st = new StringTokenizer(s);
    
    while(st.hasMoreTokens()) {
      System.out.println(st.nextToken());
    }  
  }
  
  /**
   * Split on "n" and "e".
   */
  public static void printSplitN(String s) {
    
    // The delimiter is "n" and "e".
    StringTokenizer st = 
      new StringTokenizer(s, "ne");
    
    while(st.hasMoreTokens()) {
      System.out.println(st.nextToken());
    }
  }
  
  /**
   * Reverse the string s.
   */
  public static String reverse(String s) {
    String result = "";
    int i = s.length() - 1;
    
    while(i >= 0) {
      result += s.charAt(i);
      i--;
    }
    
    /** This is equivalent:
    i = 0;
    while(i < s.length()) {
      result = s.charAt(i) + result;
      i++;
    }
    */
    
    return result;
  }
  
}
