I need help with creating a GUI program named PIG LATIN GUI that allows the user to enter a word and displays the pig Latin version.

How can i write a program that translates English word into pig Latin in visual studio?
Heather JacobsAsked:
Who is Participating?
 
MishaProgrammerCommented:
At the first, you should decide, what type of program do you want to create. For example, it may be console application with user input (user input some text, press enter key and your program write new text in console). Therefore you select corresponding template when you start to write your program (Console Appication). Or you can select Windows Forms or other more difficult templates (user select file, where your english text is located and program create new file whith new text in pig Latin).

As regards algoritm, if you deicde to use Windows Forms, you can use this example:
namespace Pig_Latin_Translator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    List<string> vowels = new List<string>();
    List<string> specials = new List<string>();

    private void TranslateButton_Click(object sender, EventArgs e)
{
   char[] specials = "`1234567890-=[]\";',./~!@#$%^&*()_+{}|:\\<>?".ToArray();
    char[] vowels = "aeiou".ToArray();

    TranslateOutput.Text = String.Empty;

    if( TranslateBox.Text.IndexOfAny( specials ) > -1 ) {
        MessageBox.Show( "No Special Characters!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning );
        return;
    }

    String[] parts = TranslateBox.Text.Split();
    foreach( String part in parts ) {
        int firstVowel = part.IndexOfAny( vowels );
        if( firstVowel > 0 ) {
            TranslateOutput.Text += part.Substring( firstVowel ) + part.Substring( 0, firstVowel ) + "ay ";
        }
        else {
            TranslateOutput.Text += part + "ay ";
        }
    }

    TranslateOutput.Text = TranslateOutput.Text.TrimEnd();
}

    private void Form1_Load(object sender, EventArgs e)
    {
	vowels.AddRange("aeiou".Select(x => x.ToString()));
	specials.AddRange(@"`1234567890-=[]\;',./~!@#$%^&*()_+{}|:""<>?".Select(x => x.ToString()));
    }

    private void AboutButton_Click(object sender, EventArgs e)
    {
        MessageBox.Show("Pig Latin is a fake language. It works by taking the first letter (Or two if it's a pair like 'th' or 'ch') and bringing it to the end, unless the first letter is a vowel. Then add 'ay' to the end. So 'bus' becomes 'usbay', 'thank' becomes 'ankthay' and 'apple' becomes 'appleay'.", "About:", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
}

Open in new window

0
 
MishaProgrammerCommented:
There is no activity from author
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.