In: Computer Science
I need the c# code for the below assignment.
Complete PigLatin program in Windows Forms GUI. Zip the solution project file and attach to this submission. Do this in the GUI format (Windows Form). Be sure and add a Clear Button to reset for entering another word or words.
PigLatinGUI
Basic Steps in Creating your Program
Your program assignment
Pig Latin is a nonsense language. To create a word in pig Latin, you remove the first letter and then add the first letter and “ay” at the end of the ford. For example, “dog” becomes “ogday” and “cat” becomes “atcay”. Write a program named PigLatin that allows the user to enter a word and display’s the pig Latin version.
For words which begin with vowel sounds or silent letter, one just adds "yay" to the end. Examples are:
Another less common way some speakers may use a different ending for words starting with vowels is adding "way" (or "wa") to the end. Examples are:
You could use the split command to enter more than one word. Indicating delimiters
char[] delimiterChars = { ' ', ',', '.', ':', ';', '\t' };
string[] words = text.Split(delimiterChars);
Below is the solution:
code:
using System;
using System.Windows.Forms;
namespace PigLatinConvert
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void
btnConvert_Click(object sender, EventArgs e)
{
{
string eng = Convert.ToString(txtWord.Text); //entered text is
store in english variable
string pl = ""; //set tle pl string variable to blank/null
string fl; //declare the fl variable for first letter of the given
word take
string restWord; //take the fl variable for remaining letter not
included the first letter
string vowels = "AEIOUaeiou"; //vowel string
int lp; //variable lp for letter position
//char[] delimiterChars = { ' ', ',', '.', ':', ';', '\t' };
//string[] words = eng.Split(delimiterChars);
foreach (string word in eng.Split())
{
fl = word.Substring(0, 1); //take the first letter of input
word
restWord = word.Substring(1, word.Length - 1); // take the remaing
letter not included first letter
lp = vowels.IndexOf(fl);
if (lp == -1)
{
//it's a consonant
pl = eng +" of Pig Latin word is: "+restWord + fl + "yay";
}
else
{
//it's a vowel
pl = eng + " of Pig Latin word is: " +word + "way";
}
lblPigLatin.Text = pl .ToString(); //display the letter in
lblPigLatin label
txtWord.Focus();
}
}
}
}
}
sample output: