finished BMI calculator
This commit is contained in:
@@ -25,28 +25,40 @@ namespace WindowsFormsApp1
|
||||
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)
|
||||
{
|
||||
Data.kg = Convert.ToDouble(textBox1.Text);
|
||||
UpdateIndex();
|
||||
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)
|
||||
{
|
||||
Data.m = Convert.ToDouble(textBox2.Text)/100;
|
||||
UpdateIndex();
|
||||
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)
|
||||
if (Data.index != null && Data.m != null && Data.m != 0)
|
||||
{
|
||||
Data.index = Data.kg / (Data.m * Data.m);
|
||||
}
|
||||
@@ -84,16 +96,16 @@ namespace WindowsFormsApp1
|
||||
case double n when n < 19.1:
|
||||
label3.Text = $"BMI:{n}\nSovány";
|
||||
break;
|
||||
case double n when n >= 20.7 && n < 27.8:
|
||||
case double n when n >= 19.1 && n < 27.3:
|
||||
label3.Text = $"BMI:{n}\nNormális";
|
||||
break;
|
||||
case double n when n >= 27.8 && n < 32.3:
|
||||
case double n when n >= 27.3 && n < 31.1:
|
||||
label3.Text = $"BMI:{n}\nTúlsúlyos";
|
||||
break;
|
||||
case double n when n >= 32.3 && n < 45.4:
|
||||
case double n when n >= 31.1 && n < 44.8:
|
||||
label3.Text = $"BMI:{n}\nKomolyan Túlsúlyos";
|
||||
break;
|
||||
case double n when n >= 45.4:
|
||||
case double n when n >= 44.8:
|
||||
label3.Text = $"BMI:{n}\nVeszélyeztetett";
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user