#C1473. Pig Latin Translator
Pig Latin Translator
Pig Latin Translator
You are given a sentence consisting of words separated by spaces. Your task is to convert the sentence into Pig Latin according to the following rules:
- If a word begins with a vowel (a, e, i, o, u), append
way
to the end of the word. - If a word begins with a consonant (or consonant cluster), move all the letters before the first vowel to the end of the word and append
ay
. - If the word ends with punctuation (one of , . ! ?), preserve the punctuation at the end.
- Preserve the word's capitalization: if the original word starts with an uppercase letter, then the resulting Pig Latin word should also start with an uppercase letter and all other letters should be in lowercase.
For example, the sentence "Hello, world!" is converted to "Ellohay, orldway!".
Note: The input will be provided via standard input (stdin) and the output should be produced to standard output (stdout).
inputFormat
Input consists of a single line, which is the sentence to be converted.
outputFormat
Output the converted sentence in Pig Latin.
## sampleHello, world!
Ellohay, orldway!
</p>