// Import statement
import java.io.*;

/**
 * This class counts the number of vowels, blank spaces,
 * and numeric characters in a string.
 * @author
 * @version 1.0
 */

public class CountCharacters {

    /* members to keep track of the counts */
    private int numberOfVowels;
    private int numberOfBlanks;
    private int numberOfNumerics;

    /* Constructor method */
    public CountCharacters(){

      numberOfVowels = 0;
      numberOfBlanks = 0;
      numberOfNumerics = 0;
    }

    /* Getter and Setter methods for private members */
    public void incrementVowels(){
      numberOfVowels++;
    }

    public int getNumberOfVowels(){
      return numberOfVowels;
    }

    public void incrementBlanks(){
      numberOfBlanks++;
    }

    public int getNumberOfBlanks(){
      return numberOfBlanks;
    }

    public void incrementNumerics(){
      numberOfNumerics++;
    }

    public int getNumberOfNumerics(){
      return numberOfNumerics;
    }


    /**
     * This method parses the string and counts and stores the number of
     * vowels, blank spaces, and numeric characters.
     * @param num The string to be processed
     * @return none
     */
    public void processString(String inputString)
    {
	    int numberOfCharacters;
	    String currentString = new String();
	    String blank = " ";

	    numberOfCharacters = inputString.length();

	    for (int i= 0; i< numberOfCharacters; i++){
			currentString = inputString.substring(i,i+1);
			//Convert to upper case to make comparison easier
			currentString = currentString.toUpperCase();
			if (currentString.compareTo("A") == 0 ||
			    currentString.compareTo("E") == 0 ||
			    currentString.compareTo("I") == 0 ||
			    currentString.compareTo("O") == 0 ||
			    currentString.compareTo("U") == 0)
			  incrementVowels();
			else if (currentString.compareTo(blank) == 0)
			  incrementBlanks();
			else if (currentString.compareTo("1") == 0 ||
			    currentString.compareTo("2") == 0 ||
			    currentString.compareTo("3") == 0 ||
			    currentString.compareTo("4") == 0 ||
			    currentString.compareTo("5") == 0 ||
			    currentString.compareTo("6") == 0 ||
			    currentString.compareTo("7") == 0 ||
			    currentString.compareTo("8") == 0 ||
			    currentString.compareTo("9") == 0 ||
			    currentString.compareTo("0") == 0)
			  incrementNumerics();
	    }
    }

    /**
     * This method gets the input string from the command line.
     * @return The string input by the user
     * @exception IOException On input error.
     * @see IOException
     */
    public String getInput() throws IOException
    {

        // Create a buffered reader using System.in
        InputStreamReader inStream = new InputStreamReader (System.in);
        BufferedReader inData = new BufferedReader(inStream);
        String inputString;

        // Read the data input on console using
     	// the readLine() method of the BufferedReader Class
	    inputString = inData.readLine();
	    return inputString;
    }


    /**
      * This main method calls a method to read in the string
   	  * and another method to count the number of vowels, blanks,
      * and numeric characters in the input string.
      *@param args Unused.
      *@return Nothing.
      *@exception IOException On input error.
      *@see IOException
      */
    public static void main( String args[]) throws IOException
    {

	//Instantiating a new object fo the CountCharacters class.
	CountCharacters count = new CountCharacters();
	String inputValue;
	System.out.print("Enter the string to be processed: ");

	//Calling the getInput() method
	inputValue = count.getInput();

	//Calling the processString() method
	count.processString(inputValue);

	System.out.println("***The number of vowels is " +
	                     count.getNumberOfVowels());
	System.out.println("***The number of blank characters is " +
	                     count.getNumberOfBlanks());
	System.out.println("***The number of numeric characters is " +
	                     count.getNumberOfNumerics());
    }

}
