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
 * @author Prof. Elizabeth Adams, James Madison University
 *
 */
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                 myToken;
		StringTokenizer        myStringTokenizer;


	// Setup the delimiters
	if (args.length == 0) 
	{
	    System.out.println("You didn't enter an expression!");
	} 
	else 
	{
	    myStringTokenizer = new StringTokenizer(args[0], 
	                    				    "+-x/%() \t\n",
                     				    true);   // Return delimiters

     	    // Tokenize the argument
	    while (myStringTokenizer.hasMoreTokens()) 
		 {
		    myToken = myStringTokenizer.nextToken();
          System.out.print(myToken);
      	 System.out.flush();

 				// Try to convert the token into a double
 		 try 
		 {
		    value = Double.parseDouble(myToken);
		    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();
	 } // end else
  } // end main
} // end class




}
