School of Engineering and Applied Science
Department of Computer Science
CSci 133 -- Introduction to Software Development
http://www.seas.gwu.edu/~csci133/spring03
Prof. Michael B. Feldman
mfeldman@gwu.edu

Lab Exercise #8
for labs meeting Friday, Mar. 7, 2003

Objectives: The purpose of this lab is to experiment with the Java StringTokenizer class. We will use this later in a project.
  1. Copy and examine programs53/CountWords.java. If you have your Lewis/Loftus book with you, this is explained on p. 169ff. Compile and run this program, entering various sentences.
  2. Using your web browser, visit the Sun API site (which is linked from the course web page) and look up the methods in java.util.StringTokenizer. Note that these methods provide a set of active-iteration controls for reading tokens from a string one at a time.
  3. Now modify CountWords so that NextToken treats the set of English punctuation characters as tokens and counts the punctuation characters (but not bkanks) separately from the words. Recompile and rerun the program and test this out.
(end of lab)