Question: /** * Converts a string to simplified Pig Latin then matching the case. The rules for simplified * Pig Latin are as follows: 1) If
/** * Converts a string to simplified Pig Latin then matching the case. The rules for simplified * Pig Latin are as follows: 1) If the word begins with a vowel (a, e, i, o, u, or y), then the * string "way" is appended. 2) If the word begins with a consonant (any letter that is not a * vowel as defined above), then the group of consonants at the beginning of the word are moved * to the end of the string, and then the string "ay" is appended. 3) If the word begins with * any other character, the original string is returned. Note 1: 'y' is always considered a * vowel. Note 2: An apostrophe that is not the first character of a word is treated as a * consonant. * * Some examples: Pig -> Igpay Latin -> Atinlay Scram -> Amscray I'd -> I'dway you -> youway * crypt -> yptcray * * @param word The word to covert to simplified Pig Latin. * @return The simplified Pig Latin of the parameter word with matching case. */ public static String pigLatin(String word) {
I've seen the solution elsewhere but my assignment requires me to do the operation of this method all within this method. In Java please.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
