CSIS 112 Lab 5—Pig Latin solution

$29.99

Original Work ?

Download Details:

  • Name: Lab-5-76npt8.zip
  • Type: zip
  • Size: 124.21 KB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (6 votes)

This assignment uses pointers to perform something done often in computer applications: the parsing of text to find “words” (i.e., strings delineated by some delimiter).

Write a program that encodes English language phrases into PigLatin. PigLatin is a form of coded language often used for amusement. Many variations exist in the methods used to form PigLatin phrases. Use the following algorithm: to form a PigLatin phrase from an Englishlanguage phrase, tokenize the phrase into words with the C++ function strtok_s(). To translate each English word into a PigLatin word, place the first letter of the English word at the end of the English word and add the letters “ay” after it. Thus, the word “jump” becomes “umpjay,” the word “the” becomes “hetay,” and the word “computer” becomes “omputercay.” Blanks between words remain as blanks. Assume that the English phrase input from the keyboard consists of words separated by blanks, there are no punctuations marks, all words have 2 or more letters, and the input phrase is less than 200 characters. Function printLatinWord() should display each word. Hint: Each time a token is found in a call to strtok_s(), pass the token pointer to function printLatinWord() and print the PigLatin word.

 

Your program should allow the user to enter phrases until he or she selects an exit option to quit.

 

In summary:  Create a PigLatin program to implement this functionality:

Prompt the user to enter a sentence.Print out the sentence, and then print out the same sentence in Pig Latin. Repeat this sequence until the user elects to quit.

 

Here is an excellent discussion of tokenizing and the strtok_s function:

https://msdn.microsoft.com/en-us/library/ftsafwz3.aspx

 

Hint:  You will likely need to create a copy of the token passed into the printLatinWord function and use pointer arithmetic to move the pointer of the token character array to make it point to the second member of the array before concatenating the token with its first letter and “ay”.

 

Here is an example of how your output might look:

 

 

 

Deliverables:

  • Complete the programming assignment described above and submit your completed assignment in accordance with the lab submission policies.