UNB/ CS/ David Bremner/ teaching/ java/ Words.java
import java.util.StringTokenizer;

public class Words
{  public static void main(String[] args)
   {  ConsoleReader console = new ConsoleReader(System.in);
      System.out.println("Enter words:");
      
      int count = 0;
      
      boolean done = false;
      while (!done)
      {  String inputLine = console.readLine();
         if (inputLine == null)
            done = true;
         else
         {  // break up input line into words
         
            StringTokenizer tokenizer 
               = new StringTokenizer(inputLine);
            while (tokenizer.hasMoreTokens())
            {  tokenizer.nextToken(); // read and discard  
               count++; // count each word
            }
         }
      }

      System.out.println(count + " words");
   }
}