An ancient language was recently uncovered which appears to be a close English language derivative. A group of researchers requires a program to translate English into this ancient text. Your task is to write a simple program to perform basic English to foreign language translation.
- If a word has no letters, don't translate it.
- All punctuation should be preserved.
- If the word begins with a capital letter, then the translated word should too. (Assumption - don't change case of any character.)
- Separate each word into two parts. The first part is called the “prefix” and extends from the beginning of the word up to, but not including, the first vowel. (The letter “y” will be considered a vowel.) The Rest of the word is called the “stem.”
- The translated text is formed by reversing the order of the prefix and stem and adding the letters “ay” to the end. For example, “sandwich” is composed of “s” + “andwich” + “ay” + “.” and would translate to “andwichsay.”
- If the word contains no consonants, let the prefix be empty and the word be the stem. The word ending should be “yay” instead of merely “ay.” For example, “I” would be “Iyay.”
Your program should perform translation one line at a time. The program will continue to accept input until it is terminated by entering the word “exit”. The program output should follow each input line. The translation rules will determine how each word is translated.
- A word is defined by spaces.
- If vowel is the first character, there is no prefix. So just add "yay" to the end. The same result for words with no consonants.
- Assumption - do not change the case of any characters.
- Some sites on internet use "way" instead of "yay".
Original | Translated | Notes |
---|---|---|
sandwich | andwichsay | |
123hope456 | ope456123hay | |
I | Iyay | No consonants |
mmm | mmmyay | No vowels |
Apple | Appleyay | Starts with vowel |
123 | 123 | If a word has no letters, don't translate it. |
NetFlix | etFlixNay | Don't change case of any letter. |
Bitter, | itter,Bay | All punctuation should be preserved. |