#C10907. Pig Latin Converter
Pig Latin Converter
Pig Latin Converter
Given an English sentence, convert each word into Pig Latin following these rules:
- If a word begins with a vowel (i.e., \(a, e, i, o, u\)), append
way
to the word. - If a word begins with a consonant, move the leading consonant or consonant cluster to the end and then append
ay
. - Preserve the capitalization of the original word. If the word is capitalized, the resulting Pig Latin word should also be capitalized.
- Preserve any punctuation attached to the word by keeping it at the end.
- Any non-alphabetic characters should remain unprocessed.
For example:
Input: Hello world! Output: Ellohay orldway!</p>Input: Eat apples every day. Output: Eatway applesway everyway ayday.
inputFormat
The input consists of a single line, which is a sentence containing words, spaces, and punctuation.
You should read the input from standard input (stdin).
outputFormat
Output the converted Pig Latin sentence to standard output (stdout). The words in the output must be separated by a single space and the punctuation attached to each word must be preserved.
## sampleHello world!
Ellohay orldway!