Problem 2: Pig Latin Translator
Background:
If you want to communicate effectively with someone, it often is essential
to speak their language. When residents of Parents-land want to communicate
with their neighbors from Children-country, this can be especially true.
At certain ages, that Children's language is Pig Latin.
Unfortunately it is a language that is beyond the
learning capability Parents. Let's help them out with a translator.
For this problem, we'll use the west coast variant of Pig Latin.
Most words are translated by moving the initial string of consonants
to the end and appending "ay" (trend -> endtray). Words beginning
with a vowel are translated by appending "way" (end --> endway).
The letter 'y' is a treated as a consonant if it appears as the first
letter of a word (yard -> ardyay), but as a vowel if it appears at an
interior location (crybaby -> ybabycray). Also, "sch" at the beginning
should become "sk" at the end (schooner -> oonerskay). Capitalized words
should be capitalized in translation (Sam -> Amsay).
Input:
The input will consist of a text to be translated.
Words will be in lower case, possibly some of them capitalized (first letter
only). Word length is never over 20 chars. You can be sure,
'ere ain't gonna be no contractions or non-helpful hyphens, or any sort
of embedded punctuation for that matter.
Output:
Write the translation, word by word. White space and
punctuation should be echoed in the output exactly as it appears in the input.
Sample Input:
Ham and cheese! Away with you, vegetable.
-- Are yellow, soft things schoolable?
Sample Output:
Amhay andway eesechay! Awayway ithway ouyay, egetablevay.
-- Areway ellowyay, oftsay ingsthay oolableskay?