Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Let
- {
- public partial class MainForm : Form
- {
- List<char> VOWELS = new List<char>();
- public bool Is_Vowel(char a)
- {
- if (char.IsUpper(a))
- a = char.ToLower(a);
- return VOWELS.Contains(a);
- }
- public MainForm()
- {
- InitializeComponent();
- VOWELS.Add('a');
- VOWELS.Add('e');
- VOWELS.Add('i');
- VOWELS.Add('u');
- VOWELS.Add('o');
- }
- private void btn_ex_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void MainForm_Load(object sender, EventArgs e)
- {
- }
- private void btn_dis_Freq_Click(object sender, EventArgs e)
- {
- if (textBox1.Text.Length < 1) return; /// return if text is empty
- string sentence = textBox1.Text;
- string res="";
- foreach (char a in sentence)
- if(Is_Vowel(a))
- res+=("'"+a.ToString()+"' >>>>> "+Letter.Frequency(a)+"%"+Environment.NewLine);
- MessageBox.Show(res);
- }
- private void conv_to_up_Click(object sender, EventArgs e)
- {
- string res="";
- foreach (char a in textBox1.Text)
- {
- if (Is_Vowel(a))
- res += (char.ToUpper(a)).ToString();
- else
- res += a.ToString();
- }
- textBox1.Text = res;
- }
- private void conv_to_low_Click(object sender, EventArgs e)
- {
- string res = "";
- foreach (char a in textBox1.Text)
- {
- if (Is_Vowel(a))
- res += (char.ToLower(a)).ToString();
- else
- res += a.ToString();
- }
- textBox1.Text = res;
- }
- private void btn_start_end_Click(object sender, EventArgs e)
- {
- if (textBox1.Text.Length < 1) return; /// return if text is empty
- bool is_start_with_vowel=false;
- bool is_End_with_vowel=false;
- int last_index = textBox1.Text.Length-1;
- is_start_with_vowel= Is_Vowel(textBox1.Text[0]);
- is_End_with_vowel=Is_Vowel(textBox1.Text[last_index]);
- if (is_start_with_vowel && is_End_with_vowel)
- MessageBox.Show("Start and end with Vowel ");
- else if (is_start_with_vowel && !is_End_with_vowel)
- MessageBox.Show("Start With Vowel ");
- else if (!is_start_with_vowel && is_End_with_vowel)
- MessageBox.Show("End With Vowel ");
- else MessageBox.Show("No Vowel in start or end");
- }
- private void btn_vowel_Loc_Click(object sender, EventArgs e)
- {
- if (textBox1.Text.Length < 1) return; /// return if text is empty
- string res = "";
- string v = textBox1.Text;
- for (int i = 0; i < v.Length; i++)
- if (Is_Vowel(v[i]))
- res += (v[i].ToString() + " at index of " + i.ToString() + Environment.NewLine);
- MessageBox.Show(v+Environment.NewLine+res,"Location Of Vowel");
- }
- private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- System.Diagnostics.Process.Start("http://en.wikipedia.org/wiki/Letter_frequency");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement