import java.io.*;
import java.util.*;

/**
 * An example that illustrates the use of the
 * StringTokenizer class
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class ExpressionTokenizer
{
    /**
     * The entry point of the application
     *
     * @param args   The command-line arguments
     */
    public static void main(String[] args) throws IOException
    {
	double                 value;
	String                 token;
	StringTokenizer        tokenizer;


	// Setup the delimiters
	if (args.length == 0) {

	    System.out.println("You didn't enter an expression!");

	} else {

	    tokenizer = new StringTokenizer(args[0], 
					    "+-x/%() \t\n",
					    true);   // Return delimiters

	    // Tokenize the argument
	    while (tokenizer.hasMoreTokens()) {

		token = tokenizer.nextToken();
		System.out.print(token);
		System.out.flush();

		// Try to convert the token into a double
		try {

		    value = Double.parseDouble(token);
		    System.out.print(" is a number");
		    System.out.flush();

		} catch (NumberFormatException nfe) {
		    
		    System.out.print(" is not a number");
		    System.out.flush();
		}

		System.out.println();
	    }
	}
    }




}
