rendered paste body
import chn.util.*;
import java.util.*;
public class Easter // change to Piglatinator
{
public static void main(String[] args)
{
ConsoleIO console = new ConsoleIO();
int countVowels = 0;
int countFIRST = 0;
int indexVowel;
char firstVowel = 'a';
char x;
char y;
char characterExit;
char checkFirstCharacter;
String englishWords;
String pigLatinWord;
String englishWords1;
String sr1;
String sr2;
String start;
String end;
System.out.println("Welcome to the Piglatinator!");
System.out.println("This program converts english to piglatin.");
System.out.println("");
do
{
System.out.println("Please type an English sentence or phrase and then press <Enter>. ");
englishWords= console.readLine();
characterExit = englishWords.charAt(0);
//set values the same
checkFirstCharacter = characterExit;
//loop input (the words) length
for (int count = 0; count < englishWords.length(); count++)
{
//check each index(char) of english word
x = englishWords.charAt(count);
//upper and lower case vowels
if (x == 'a' || x == 'e' || x == 'i' || x == 'o'
|| x == 'u'|| x == 'A' || x == 'E' || x == 'I' || x == 'O' || x == 'U')
{
countVowels++;
}
}
//find FIRST vowel
for (countFIRST = 0; countFIRST <= englishWords.length(); countFIRST++)
{
y = englishWords.charAt(countFIRST);
//upper and lower case vowels
if (y == 'a' || y == 'e' || y == 'i' || y == 'o'
|| y == 'u'|| y == 'A' || y == 'E' || y == 'I' || y == 'O' || y == 'U')
{
firstVowel = y;
break;
}
}
StringTokenizer sr = new StringTokenizer(englishWords);
while(sr.hasMoreTokens())
{
sr1 = sr.nextToken();
//first vowel
indexVowel = sr1.indexOf(firstVowel);
//words up to first vowel
start = sr1.substring(0,indexVowel);
//all words after vowel
end = sr1.substring(indexVowel);
//no vowels
if(countVowels == 0)
{
System.out.print(sr1 +"ay ");
}
//starting with lower case vowels or upper case vowels
else if(checkFirstCharacter == 'a' || checkFirstCharacter == 'e' || checkFirstCharacter == 'i' || checkFirstCharacter == 'o' || checkFirstCharacter == 'u' ||
checkFirstCharacter == 'A' || checkFirstCharacter == 'E' || checkFirstCharacter == 'I' || checkFirstCharacter == 'O' || checkFirstCharacter == 'U')
{
System.out.print(sr1 +"yay ");
}
//vowels not first character
else if(countVowels >= 0 && !(checkFirstCharacter == 'a' || checkFirstCharacter == 'e' || checkFirstCharacter == 'i' || checkFirstCharacter == 'o' || checkFirstCharacter == 'u' ||
checkFirstCharacter == 'A' || checkFirstCharacter == 'E' || checkFirstCharacter == 'I' || checkFirstCharacter == 'O' || checkFirstCharacter == 'U' ))
{
System.out.print(end + start + "ay ");
}
}
System.out.println("");
//enter N or n to exit
}while( !(characterExit == 'N' || characterExit == 'n'));
}
}