write a program that translates an English text into Pig-Latin (see rules below)
ID: 3653758 • Letter: W
Question
write a program that translates an English text into Pig-Latin (see rules below). It comes with a starter project that includes 4 buttons. Clear is alreay implemented but you need to add eventhandlers for Select File, Translate, and Save Translation. To create the event handlers go to Design View and double click the buttons. Select File allows the user to selet a file and displays it in the TextBox OriginalTb. Save Translations allows the user to select a file where the content of the TextBox PigLatinTb should be saved to. Pig Latin Rules: Rule1: If the string begins with a vowel, add "way" to the string. (vowels are a,e,i,o,u) Examples: Pig-Latin for "orange" is "orangeway", Pig-Latin forExplanation / Answer
#include #include #include //Welcomes the user to the pigLatin program void Welcome( ); //Displays a list of instructions for the user void DisplayInstructions( ); //Allows the user to quit the program or enter another word void Again(int *quitPtr); //This function determines which rule is applied to the word entered by the user int DetermineRule(char word[ ]); //This function is for rule 1. It transforms the word to pigLatin if the word begins //with TH,CH,SH,PH,Wh, or QU void ApplyOne(char word,char newWord); //This function is for rule 2. It transforms the word to pigLatin if the word begins //with A,E,I,O, or U. void ApplyTwo(char word, char newWord); //This function is for rule 3. It transforms the word to pigLatin if the word //does not apply to rule 1 or rule 2. void ApplyThree(char word, char newWord); //This function displays the transformed pigLatin word onto the screen int main( ) { int yes; int quitPtr; char word[20]=" "; char newWord[20]=" "; int len; int rule; //Welcomes the user to the pigLatin program Welcome( ); //Displays a list of instructions for the user DisplayInstructions( ); printf(" Would you like to enter a word? "); printf("Enter 1 to continue, anything else will quit. "); scanf("%d",&yes); while(yes == 1) //This loop keeps the program running if 1 is entered by the user when prompted above { printf("Please enter the word: "); scanf("%s",word); printf("The word you entered is: %s ",word); printf("------------------------------ "); strcpy(newWord," "); rule=DetermineRule(word); len=strlen(word); printf(" The rule is %d",rule); Again(&quitPtr); //Allows the user to quit the program or enter another word yes = quitPtr; } return 0; } void Welcome( ) //Welcomes the user to the pigLatin program { printf("Welcome to the pigLatin program! "); printf("-------------------------------- "); } void DisplayInstructions( ) //Displays a list of instructions for the user { printf("You will enter a word. "); printf("and the word will be transformed into Pig Latin. "); printf("------------------------------------------------"); } void Again(int *quitPtr) //Allows the user to quit the program or enter another word { printf(" Enter 1 to continue. "); printf("Anything else will quit the program."); scanf("%d",quitPtr); } int DetermineRule(char word[ ])//This function determines which rule is applied to the word entered by the user { int i; int len; char let[3]=" "; strncpy(let,word,2); let[2] = ''; len=strlen(let); //This line is the one that is giving error for (i=0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.