/**
 * Count the number of vowels in a String
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class VowelCounter
{
    /**
     * The entry point
     *
     * @param args   The command-line arguments
     */
    public static void main(String[] args)
    {
       char               letter;       
       int                n, vowels;
       String             line;

       JMUConsole.open();

       // Prompt for and read the text
       JMUConsole.printf("Enter the text: ");
       line = JMUConsole.readLine();

       // Get the length of the String (in characters)
       n = line.length();
       
       // Initialize the accumulator
       vowels = 0;
       
       // Loop through the String
       for (int i=0; i<n; i++)
       {
          // Get the next letter
          letter = line.charAt(i);           

          // Check if it's a vowel (this can be done more efficiently)
          if ((letter == 'a') || (letter == 'e') || (letter == 'i') ||
              (letter == 'o') || (letter == 'u') ||
              (letter == 'A') || (letter == 'E') || (letter == 'I') ||
              (letter == 'O') || (letter == 'U')                      )
          {
             vowels++;             
          }
       }
       
       // Print the answer
       JMUConsole.printf("Vowels: %d\n", vowels);

       JMUConsole.close();
    }
}
