Topical Information

This project will help you show your mastery of strings (and branching, looping, functions, etc.).

Background Information

Pig Latin is a commoner's tongue from the middle ages. It was developed to make the common man sound as fancy as his/her lord. It has nothing to do with pigs or Latin. [Or maybe Jason is just making all that up... But it is a 'real' language in use by millions every day. See the Wikipedia entry for more information — just ignore that bit about programming it with recursion; you still aren't allowed to use recursion!]

To form a Pig Latin word from an English word, you first determine if the first letter is a vowel or consonant (vowels are a, e, i, o, u and sometimes y — at least for the sake of this discussion). If it is a consonant, remove its consonant group (all consonants up to a vowel; but watch out for qu since it acts together as a consonant), move this group to the rear of the word, and add "ay" after it. If the first letter is a vowel, leave it there and simply append "yay" to the end of the word.

For example:

EnglishPig Latin EnglishPig Latin Commentary
isisyay aayay vowel start
formormfay tootay consonant start
thememthay theethay consonant group start
throughoughthray scrollollscray [longer] consonant group start
qat atqay quadadquay q vs. qu start
yellowellowyay skyyskay y start vs. y as vowel

(Note in the bottom two examples how y is treated as a consonant at the beginning of a word but as a vowel inside/at the end of a word.)

Here's a whole paragraph of samples:

    This is the winter of our discontent!
    My dog has 376 fleas.
    The rancid dogs of war move into our shallow graves.
    Happy Gilmore has won the Pennant!
    Trolls stroll through the quad as Brian and his scruffy pooch await the scrumptious cat stuck in a tall qat.

It would become:

    Isthay isyay ethay interway ofyay ouryay iscontentday!
    Ymay ogday ashay 376 easflay.
    Ethay ancidray ogsday ofyay arway ovemay intoyay ouryay allowshay avesgray.
    Appyhay Ilmoregay ashay onway ethay Ennantpay!
    Ollstray ollstray oughthray ethay adauay asyay Ianbray andyay ishay uffyscray oochpay awaityay ethay umptiousscray atcay uckstay inyay ayay alltay atqay.

(Note how capitalization transfers to the new first letter. Note also how punctuation is not considered part of the word.)

Program Information

Write an English to Pig Latin translator. The user types in their sentence(s) (having a sentence end with a \n is acceptable) and you print them back out in Pig Latin.

In addition to the notes above, also watch out for the occasional word which has neither vowels nor consonants. And when watching for punctuation and/or word boundaries, note that ' (single quotes; ticks) are used as not only quoting symbols but also contractions and possessive formation! Whether you decide that a hyphenated word is a single unit or two separate parts is up to you, but make your choice clear in the comments.

Be sure to let the user repeat the entry/translation cycle as many times as they want.

This assignment is (Level 6).

Options


Total Level Possible

If you did all above options, this project could be worth as much as (Level 21.5).