Question: Program Description: This is a not an ordinary Pig Latin. Write a program that reads a sentence as input and converts each word from English




Program Description: This is a not an ordinary Pig Latin. Write a program that reads a sentence as input and converts each word from English to "Pig Latin". In this version, to convert a word to Pig Latin you would follow the following steps: 1. first convert the sentence to upper case, 2. find the substring "ig" (regardless of case). If there is one, remove the rest of the sentence include "ig". 3. and then you append the c-string "ay" (in lower case) to the end of the sentence. 4. Reverse the sentence 5. append the length of the sentence to the end. * notice in the last example, I-G is NOT continuous, so it not the same as "IG" Repeat until user has entered a "QUIT" (regardless of case). You are required to use c-strings for this program. Use functions for c-strings discussed in class. Functions: Main function should be shorter than half a page. \begin{tabular}{|l|l|} \hline \multicolumn{1}{|c|}{ Function header } & \multicolumn{1}{|c|}{ Explanation } \\ \hline void convertToUpper(char * str) & This function should covert the given c-string to upper cases \\ \hline void findAndRemove(char* str) & Thisfunctionshouldfindthesubstring"IG"inthegivenc-string,andremovetherestofthec-stringinclude"IG" \\ \hline \end{tabular} \begin{tabular}{|l|l|} \hline void appendAy(char* str) & Thisfunctionshouldonlybecalledwhenyouhavesuccessfullyremoved"IG"andtheremainingstring.Appenda"ay"(lowercase)towardstheendofthec-string. \\ \hline void reverse(char * str) & Thisfunctionwilltaketheinputc-stringparameterandreversethecontent.Forexample,iftheoriginalstris"hello",thefunctionshouldchangestrto"olleh".Youshouldaddaswapfunctionforcharsforthistask. \\ \hline void convertPigLatin(char * str) & Thisfunctionshouldprovideado-whileloop(orawhileloop)toconvertuserinputtouppercasefirst,thencalls"findAndRemove"and"appendAy"inthatorder.Noticeyourprogramshouldstopassoonasuserhasentereda"quit"messageregardlessofthecase(e.g."Quit"isacceptable,butnot"Quitting"or"Quit!").Displayamessage"Quit!"whentheprocessisfinished. \\ \hline \end{tabular} 1. "ay" will be attached to the end of the c-string regardless 2. No inputs are longer than 180 characters, guaranteed. 3. No input validation needed. (everything and anything has a corresponding interpretation in Pig Latin) 4. If user enters a "quit", you don't need to convert to pig latin 5. You should write a swap function for chars. Other requirements: 1. C-string(s) should be dynamically allocated. All memory dynamically allocated should be freed as soon as you are finished with a task. 2. Use functions as provided in the section above. Functions should not be modified. 3. Follow programming style guideline very carefully. a. Points will be taken off for all violations 4. Your output style has to match with my output shown below (although you can try different user input). 5. When accessing array, use only pointer syntax. You should only use ptr or * ptr for accessing memory addresses or values. 6. NO global variables permitted 7. All functions must have prototypes. 8. Store all values as variables, do not hardcode any values (for example: size should be saved as a variable). Use constant variables as much as possible a. const int SIZE =181; 9. Use a line separator between all function definitions. (//****101stars******, blank line before and after) 10. All assignments must be submitted and run as specified to pass the course (see syllabus) 11. Copy and paste your output at the end of your program. Comment out the output lines. 12. Submit your program (.cpp only) on world classroom before deadline Sample Output: Enter a string, enter quit to stop the process night yaN3 Enter a string, enter quit to stop the process niGHT yaN3 Enter a string, enter quit to stop the process no ig here ya ON5 Enter a string, enter quit to stop the process no i-g here yaEREH G-I ON13 Enter a string, enter quit to stop the process First they ignore you, then they laugh at you, then they fight you, then you win. ya YEHT TSRIF13 Enter a string, enter quit to stop the process then they fight you, then you win. yaF YEHT NEHT13 Enter a string, enter quit to stop the process over yaREVO6 Enter a string, enter quit to stop the process quit Quit! Program ended with exit code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
