import javabook.*;

/*
 * Introduction to OOP with Java 2nd Edition, McGraw-Hill
 *	
 *   Count the number of vowels in a given string.
 *  
 * @author Dr. Caffeine
 *
 */
class CountVowels
{
    public static void main (String[] args)
    {
        MainWindow  mainWindow;
        MessageBox 	messageBox;
        InputBox    inputBox;
        
        mainWindow  = new MainWindow("Count Vowels in Your Name");
        messageBox  = new MessageBox( mainWindow );
        inputBox    = new InputBox( mainWindow );
                
        mainWindow.setVisible( true ); 
        
        String    name;

        int       numberOfCharacters, 
                  vowelCount = 0;
        
        char      letter;
        
        name = inputBox.getString("What is your name?");
        numberOfCharacters = name.length();
        
        for (int i = 0; i < numberOfCharacters; i++) {
          
            letter = name.charAt(i);
          
            if (   letter == 'a' || letter == 'A' ||
                   letter == 'e' || letter == 'E' ||
                   letter == 'i' || letter == 'I' ||
                   letter == 'o' || letter == 'O' ||
                   letter == 'u' || letter == 'U'     ) {
              
                vowelCount++;
            }
        }

        messageBox.show(name + ", your name has " +
                        vowelCount + " vowels");
        
            
    }
    
}