/* * File: PigLatin.java * Author: Java Java Java Staff * Description: This class translates a string into Pig Latin, using * the following rules: * 1) If the word begins with a consonant, divide the word at the * first vowel, swap the front and back halves, and add "ay" to * the end: Latin --> atinLay, String --> ingStray * 2) If the word begins with a vowel, append "yay" to it. * ice --> iceyay * 3) If the word has no vowels, append "yay" to it: "my" --> "myyay" */ import java.util.StringTokenizer; public class PigLatin { /** * translate() translates its parameter into Pig Latin * using the rules given above. * @param s -- a String representing a sentence * @return a String giving Pig Latin translation of s * Algorithm: Note the use of StringTokenizer to break up the * sentence and StringBuffer to build the result string. */ public static String translate (String s) { //Insert your code here } /** * translateWord() translates its parameter into Pig Latin * using the rules given above. * @param s -- a String representing a word * @return a String giving Pig Latin translation of s */ private static String translateWord (String s){ StringBuffer result = new StringBuffer(""); //Insert your code here return result.toString(); } // translateWord() /** * findFirstVowel() finds the first vowel in its parameter * and returns its index. It returns 0 if no vowel is found. * @param s -- a String representing a word * @return an int giving the index of the first vowel */ private static int findFirstVowel (String s){ //Insert your code here } // findFirstVowel() } // PigLatin