Structured Programming in C++
Prof. Gregory Safko
Camden County College, Cherry Hill Campus
Project 2
Assigned: April 9, 2004
Due: May 7, 2004
Pig-Latin Processor
Write a program (Project2.cpp) that will ask the user for a word, and will return its representation in Pig Latin.
As a brief primer, to convert a word into Pig Latin, you take the first letter of the word, move it to the end of the word, and add “ay” to the end.
You code will work in the following way:
Enter a word: College
In Pig Latin: ollegecay
(Notice the uppercase and lowercase differences between the entered word, and the Pig Latin word)
There are rules to Pig Latin, however. They are as follows:
1. If the word begins with more than one consonant, move all those consonants (until you reach a vowel) to the end, and then add “ay” as before.
Another sample run (based on the preceding rule)
Enter a word: Friday
In Pig Latin: idayfray
Yet another sample run (based on the preceding rule)
Enter a word: strong
In Pig Latin: ongstray
2. Another rule in Pig Latin deals with words that begin with vowels. If a word begins with a vowel, just add “yay” to the end (If the word already ends in 'y', just add "ay" to the end)
A sample run (based on the preceding rule)
Enter a word: October
In Pig Latin: octoberyay
Another sample run (based on the preceding rule)
Enter a word: oily
In Pig Latin: oilyay
3. If a word has no vowels, just add “yay” to the end. If the word already ends in ‘y’, just add ‘ay’ at the end. (As a reminder, for Pig Latin, the letter ‘y’ is not considered a vowel)
A sample run (based on the preceding rule)
Enter a word: Rhythm
In Pig Latin: rhythmyay
Another sample run (based on the preceding rule)
Enter a word: sly
In Pig Latin: slyay
4. If a word begins with a ‘q’ (or contains a ‘q’ before a vowels is found), then the following letter is most likely a ‘u’, so remove the “qu” (and any additional letters that precede the “qu”), move them to the end, and “ay” to the end
A sample run (based on the preceding rule)
Enter a word: quick
In Pig Latin: ickquay
Another sample run (based on the preceding rule)
Enter a word: squid
In Pig Latin: idsquay
Some hints and rules:
Assumptions:
Submission Requirements
PIG LATIN RULES
Although many sites and source have variations on the rules of Pig Latin, the following are used for this project:
· For words that begin with a vowel, just add 'yay' to the end of the word. (if the word ends in a ‘y’, just add ‘ay’)
· For words that have no vowels, just add ‘yay” (if the word ends in a ‘y’, just add ‘ay’)
· For words that begin with a consonant, put the consonant at the end of the word, and add 'ay' on the end of that.
· For words that begin with two or more consonants, put them at the end of the word and add 'ay'.
· For words that begin with a ‘qu’, move the qu to the end and add ‘ay’