Pig Latin Assignment                                                                                                                 

 

Complete the function TranslateToPigLatin.  It should encode English language phrases into pig Latin.  Pig Latin is a form of coded language often used for amusement.  Many variations exist in the methods used to form pig Latin phrases.  For consistency, use the following algorithm:


For words that begin with a single consonant take the consonant off the front of the word and add it to the end of the word. Then add ay after the consonant. Here are some examples:

cat = atcay       dog = ogday    simply = implysay       noise = oisenay


For words that began with double or multiple consonants take the group of consonants off the front of the word and add them to the end, adding ay at the very end of the word. Here are some examples:


scratch = atchscray      thick = ickthay            flight = ightflay           grime = imegray

 

For words that begin with a vowel, just add yay at the end. For example:

is = isyay         apple =appleyay          under = underyay        octopus = octopusyay

 

For simplicity sake we will consider y a consonant.

 

Example Run:

Please enter a phrase to be translated to Pig Latin:

this is a test

isthay isyay ayay esttay

 

I will use the following main function to test your function.  Add additional functions where appropriate.

#include<iostream>

using namespace std;

 

void TranslateToPigLatin(char Phrase[]);

const int MAX_PHRASE_LENGTH = 1000;

const int MAX_WORD_LENGTH = 100;

 

void main()

{

      char Phrase[MAX_PHRASE_LENGTH];

     

      cout << "Please enter a phrase to be translated to Pig Latin:" << endl;

      cin.getline(Phrase, MAX_PHRASE_LENGTH);

 

      TranslateToPigLatin(Phrase);

 

      cout << Phrase << endl;

}

 

void TranslateToPigLatin(char Phrase[])

{

      //Your work goes here

      //Add functions where appropriate

      strcpy(Phrase,"The original phrase now in pig Latin");

}