using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void label1_Click(object sender, EventArgs e) { } private void radioButton1_CheckedChanged(object sender, EventArgs e) { MaleCheck(); Category(); } private void radioButton2_CheckedChanged(object sender, EventArgs e) { MaleCheck(); Category(); } private void textBox1_TextChanged(object sender, EventArgs e) { bool noletters = textBox1.Text.Any(x => !char.IsLetter(x)); if (textBox1.Text != "" && noletters) { Data.kg = Convert.ToDouble(textBox1.Text); UpdateIndex(); Category(); } } private void textBox2_TextChanged(object sender, EventArgs e) { bool noletters = textBox2.Text.Any(x => !char.IsLetter(x)); if (textBox2.Text != "" && noletters) { Data.m = Convert.ToDouble(textBox2.Text) / 100; UpdateIndex(); Category(); } } public void UpdateIndex() { if (Data.index != null && Data.m != null && Data.m != 0) { Data.index = Data.kg / (Data.m * Data.m); } } public void Category() { if (Data.male) { switch (Data.index) { case double n when n < 20.7: label3.Text = $"BMI:{n}\nSovány"; break; case double n when n >= 20.7 && n < 27.8: label3.Text = $"BMI:{n}\nNormális"; break; case double n when n >= 27.8 && n < 32.3: label3.Text = $"BMI:{n}\nTúlsúlyos"; break; case double n when n >= 32.3 && n < 45.4: label3.Text = $"BMI:{n}\nKomolyan Túlsúlyos"; break; case double n when n >= 45.4: label3.Text = $"BMI:{n}\nVeszélyeztetett"; break; default: break; } } else { switch (Data.index) { case double n when n < 19.1: label3.Text = $"BMI:{n}\nSovány"; break; case double n when n >= 19.1 && n < 27.3: label3.Text = $"BMI:{n}\nNormális"; break; case double n when n >= 27.3 && n < 31.1: label3.Text = $"BMI:{n}\nTúlsúlyos"; break; case double n when n >= 31.1 && n < 44.8: label3.Text = $"BMI:{n}\nKomolyan Túlsúlyos"; break; case double n when n >= 44.8: label3.Text = $"BMI:{n}\nVeszélyeztetett"; break; default: break; } } } public void MaleCheck() { if (radioButton1.Checked) { Data.male = true; } else { Data.male = false; } } } public static class Data{ public static double kg; public static double m; public static double index; public static bool male; } }