You will be creating a program that translates Pig Latin to English and Vice-Versa.

{
Consider the next word in the phrase.
Place the first letter of the word at the end of the word.
Add the letters ay or tay to the end of the word.
Continue until there are no more words.
}

For example, the above algorithm translated into Pig Latin would be:

{
Onsidercay hetay extnay ordway nitay hetay hrasepay.
Lacepay hetay irstfay etterlay fotay hetay ordway tatay hetay ndetay fotay hetay ordway.
Ddatay hetay etterslay yatay rotay aytay hetay ndetay fotay hetay ordway.
Ontinuecay ntilutay heretay reatay onay oremay ordsway.
}

Guidelines:

Although there are many different dialects of Pig Latin, your program will use the rules for the General Modified Universal (GMU) dialect of the language:

  • If the English word begins with a consonant, then the first letter is placed at the end of the word and the suffix "ay" is appended.
  • If the English word begins with a vowel, then the first letter is placed at the end of the word and the suffix "tay" is appended.
  • If the English word is one character long, then the suffix "tay" is appended.

Your program must be able to use correct punctuation and capitalization as shown in the above example. For instance, the word "Place" should become "Lacepay" and not "lacePay" in order to keep the capitalization and punctuation consistent. The only punctuation you need to worry about are periods, commas, colons and semi-colons. You may assume that input text will not contain quotation marks or apostrophes.

You will then write a function that translates Pig Latin phrases back into English. Declare and implement the function "TranslateToEnglish()" in order to accomplish this. Your Menu should include this new option, as well as a way to allow the user to input a phrase in Pig Latin, which may then be translated back to English by your program.

Implementation:

  • You should create two standard queues, implemented using singly linked lists, to hold your phrases.
  • The head pointer to the first queue should be named EnglishPhrase (or something similar), and it should point to the head of a singly linked list containing the original English phrase.
  • The head pointer to the second queue should be named PigLatinPhrase (or something similar), and it should point to the head of a singly linked list containing the translated Pig Latin phrase.
  • You will also need to write a menu-driven routine that will allow users to test your program.
  • This menu should allow users to (1) input a phrase in English; (2) translate the current phrase from English to Pig Latin; and (3) print either the original phrase or the translated phrase to the screen.

Below is a suggested struct definition for the individual nodes of your linked lists:

#define MAX_WORD_CHARS (30)
typedef struct WordNodeType
{
char word[MAX_WORD_CHARS];
struct WordNodeType *next;
}WordNode;

Whatever the definition for your node, you will need to implement the following functions:

WordNode* translateWord (WordNode* NextWord)

Precondition: NextWord is passed in as a parameter and points to a WordNode containing and English word.

Postcondition: A pointer to a new node containing the Pig Latin translation of NextWord is returned to the calling function using a return statement. NextWord remains unchanged.

void printPhrase (WordNode* Phrase)

Precondition: None.

Postcondition: If Phrase points to a valid linked list, all the words contained in the list have been printed in the order that they appear in the list.

If Phrase is a NULL pointer, an appropriate message is printed.

Add whatever additional functions and variables you wish to implement the program.

As long as you properly implement the queues using linked lists of nodes allocated using memory from the heap, together with the above two functions, you may implement the remainder of your Pig Latin translation program however you like.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.