Pig Latin translator
A group of Vatican City police officers are planning a trip to the United
States. Since they only speak Pig Latin, they will need to translate a lot of
English phrases. Write a simple program to perform basic English to Pig Latin
- 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
- 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
- The Pig Latin 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
. and would translate to
- If the word contains no consonents, 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
Your first task is to produce a function that takes one argument, a word, and
returns the portion of the word up to, but not including the first vowel. For
example, if you sent
'banana' to your function, it should
'Sibley' should return
'stream' should return
'break' should return
'br'. Print out your working
function and a sample run.
Using what you learned from Phase 1, write a function (or functions) that takes
a single word as an argument and returns the word with the prefix and stem
Modify the function from Phase 2 to properly handle the
ay word ending,
capital letters, and punctuation.
Your program should perform translation one line at a time. The program will
continue to accept input until it is terminated by a Ctrl-D character.
Program output should follow each input line. The translation rules will
determine how each word is translated.
--> No littering
--> No shirts, no shoes, no service
Onay irtsshay, onay oesshay, onay ervicesay
--> No persons under 14 admitted
Onay ersonspay underay 14 admitteday
--> Hey buddy, get away from my car!
Eyhay uddybah, etgay awayyay omfray ymay arcay!