import javabook.*;

/*
 * Introduction to OOP with Java 2nd Edition, McGraw-Hill
 *	
 *   Count the number of vowels in a given string. This
 *   version uses the toUpperCase method to convert
 *   the characters in the input string to the upper case.
 *  
 * @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, nameUpper;

        int       numberOfCharacters, 
                  vowelCount = 0;
        
        char       letter;
        
        name = inputBox.getString("What is your name?");
        
        numberOfCharacters = name.length();
        nameUpper = name.toUpperCase();
        
        for (int i = 0; i < numberOfCharacters; i++) {
        
            letter = nameUpper.charAt(i);
          
            if ( letter == 'A' ||
                 letter == 'E' ||
                 letter == 'I' ||
                 letter == 'O' ||
                 letter == 'U'     ) {
              
                vowelCount++;
            }
        }
        
        messageBox.show(name + ", your name has " + 
                    vowelCount + " vowels");
        
            
    }
    
}