@@ -0,0 +1,3344 @@
+//********************************************************************%0A//  PigLatinTranslator.java       Author: Lewis/Loftus/Cocking%0A//%0A//  Represents a translation system from English to Pig Latin.%0A//  Demonstrates method decomposition and the use of StringTokenizer.%0A//********************************************************************%0Aimport java.util.Scanner;%0Apublic class PigLatinTranslator%0A%7B%0A    //-----------------------------------------------------------------%0A    //  Translates a sentence of words into Pig Latin.%0A    //-----------------------------------------------------------------%0A    public String translate (String sentence)%0A    %7B%0A        String result = %22%22;%0A        sentence = sentence.toLowerCase();%0A        Scanner scan = new Scanner (sentence);%0A        while (scan.hasNext())%0A        %7B%0A            result += translateWord (scan.next());%0A            result += %22 %22;%0A        %7D%0A        return result;%0A    %7D%0A    //-----------------------------------------------------------------%0A    //  Translates one word into Pig Latin. If the word begins with a%0A    //  vowel, the suffix %22yay%22 is appended to the word. Otherwise,%0A    //  the first letter or two are moved to the end of the word,%0A    //  and %22ay%22 is appended.%0A    //-----------------------------------------------------------------%0A    private String translateWord (String word)%0A    %7B%0A        String result = %22%22;%0A        if (beginsWithVowel(word))%0A            result = word + %22yay%22;%0A        else%0A        if (beginsWithBlend(word))%0A            result = word.substring(2) + word.substring(0,2) + %22ay%22;%0A        else%0A            result = word.substring(1) + word.charAt(0) + %22ay%22;%0A        return result;%0A    %7D%0A    //-----------------------------------------------------------------%0A    // Determines if the specified word begins with a vowel.%0A    //-----------------------------------------------------------------%0A    private boolean beginsWithVowel (String word)%0A    %7B%0A        String vowels = %22aeiou%22;%0A        char letter = word.charAt(0);%0A        return (vowels.indexOf(letter) != -1);%0A    %7D%0A    //-----------------------------------------------------------------%0A    //  Determines if the specified word begins with a particular%0A    //  two-character consonant blend.%0A    //-----------------------------------------------------------------%0A    private boolean beginsWithBlend (String word)%0A    %7B%0A        return ( word.startsWith (%22bl%22) %7C%7C word.startsWith (%22sc%22) %7C%7C%0A            word.startsWith (%22br%22) %7C%7C word.startsWith (%22sh%22) %7C%7C%0A            word.startsWith (%22ch%22) %7C%7C word.startsWith (%22sk%22) %7C%7C%0A            word.startsWith (%22cl%22) %7C%7C word.startsWith (%22sl%22) %7C%7C%0A            word.startsWith (%22cr%22) %7C%7C word.startsWith (%22sn%22) %7C%7C%0A            word.startsWith (%22dr%22) %7C%7C word.startsWith (%22sm%22) %7C%7C%0A            word.startsWith (%22dw%22) %7C%7C word.startsWith (%22sp%22) %7C%7C%0A            word.startsWith (%22fl%22) %7C%7C word.startsWith (%22sq%22) %7C%7C%0A            word.startsWith (%22fr%22) %7C%7C word.startsWith (%22st%22) %7C%7C%0A            word.startsWith (%22gl%22) %7C%7C word.startsWith (%22sw%22) %7C%7C%0A            word.startsWith (%22gr%22) %7C%7C word.startsWith (%22th%22) %7C%7C%0A            word.startsWith (%22kl%22) %7C%7C word.startsWith (%22tr%22) %7C%7C%0A            word.startsWith (%22ph%22) %7C%7C word.startsWith (%22tw%22) %7C%7C%0A            word.startsWith (%22pl%22) %7C%7C word.startsWith (%22wh%22) %7C%7C%0A            word.startsWith (%22pr%22) %7C%7C word.startsWith (%22wr%22) );%0A    %7D%0A%7D%0A%0A

Create PigLatinTranslator.java