import javabook.*;

/*
 * Introduction to OOP with Java 2nd Edition, McGraw-Hill
 *	
 *   Replace every vowel in a given sentence with 'X'.
 *   Use StringBuffer for string manipulation.
 *  
 * @author Dr. Caffeine
 *
 */
class ReplaceVowelsWithX
{
    public static void main (String[] args)
    {
        MainWindow  mainWindow;
        OutputBox 	outputBox;
        InputBox    inputBox;
        
        mainWindow  = new MainWindow("Replace Vowels");
        outputBox   = new OutputBox( mainWindow );
        inputBox    = new InputBox( mainWindow );
                
        mainWindow.setVisible( true ); 
        outputBox.setVisible( true );
        
        StringBuffer    tempStringBuffer;
        String          inSentence;
        
        int             numberOfCharacters;
        char            letter;
        
        inSentence         = inputBox.getString("Enter a sentence:");
        tempStringBuffer   = new StringBuffer(inSentence);
        
        numberOfCharacters = tempStringBuffer.length();
        
        for (int index = 0; index < numberOfCharacters; index++) {
          
          letter = tempStringBuffer.charAt(index);
        
          if ( letter == 'a' || letter == 'A' ||
               letter == 'e' || letter == 'E' ||
               letter == 'i' || letter == 'I' ||
               letter == 'o' || letter == 'O' ||
               letter == 'u' || letter == 'U'     ) {
            
            tempStringBuffer.setCharAt(index,'X');
          }
        }
        
        outputBox.printLine( "Input:  " + inSentence );
        outputBox.skipLine( 1 );
        outputBox.printLine( "Output: " + tempStringBuffer );
                    
    }
    
}