Pig Latin - FrankLand

advertisement
C++
Pig Latin Translator
Programming Assignment
Project Description
You are to write a C++ program that accepts a line of English and translates that into the form of
Pig Latin described below. Pig Latin is a word game commonly used by children, but it will also help
you learn to use c-type strings more effetively.
This program will accept its input from the keyboard and then return its answer to the console.
Eventually, you may be asked to alter this program so it will process entire files, so keep your
implementation modular and documented so you can reuse this code.
Pig Latin
There is no standard Pig Latin, so for the sake of this project, I will define the rules that you will be
graded against.

Rule 1: Words beginning with consonants. Find the first vowel in the word. Move all consonants
that come before that vowel to the end of the word and then append “ay”. If the word is capitalized,
the new word’s first letter is now capitalized. If the word begins or ends with a punctuation mark,
that punctuation mark stays at the beginning or end of the new word.

Ex: John Measel becomes Ohnjay Easelmay

Ex: third person becomes irdthay ersonpay

Ex: Wow! Becomes Owway!

Rule 2: Words beginning with vowels. Append “way” to the word. Again, capitalization and
punctuation are the same as in rule 1.

Ex: one on one becomes oneway onway oneway

Ex: An almost identical Afghan becomes Anway almostway identicalway Afghanway

Rule 3: Y as a vowel. Some words do not contain any vowels. Rhythm is an example. The Y
acts as a vowel, so your translator should treat it as one. If Y is the first letter of the word, it should
never be treated as a vowel. If the word contains a Y that comes before an A, E, I, O, or U but not
as the word’s first letter, then it should be treated as a vowel.

Ex: “Rhythm and Blues” becomes “Ythmrhay andway Uesblay”

Ex: Tryst becomes Ysttray

Ex: Yodel becomes Odelyay

Ex: Rhythmic becomes Yhtmicray

Rule 4: Words without vowels (Y or otherwise). These words can be real words such as tsk or
jargon or slang such as B8ZS. These words are translated by appending Way to them.
Capitalization is not altered.

Ex: R2D2 becomes R2D2way

Ex: “tsk, tsk” becomes “tskway, tskway”

Rule 5: Symbols and numbers. Symbols such as telephone numbers, $3.99, #$*&$#, etc, are all
to remain unchanged!

Ex: 867-5309 becomes 867-5309

Ex: “CP3O said #&(*(&%!” becomes “CP3Oway aidsay #&(*(&%!”
Download