TODO BMI calculator
This commit is contained in:
124
20240327/WindowsFormsApp1/Form1.cs
Normal file
124
20240327/WindowsFormsApp1/Form1.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
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();
|
||||
}
|
||||
|
||||
private void radioButton2_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
MaleCheck();
|
||||
}
|
||||
|
||||
private void textBox1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
Data.kg = Convert.ToDouble(textBox1.Text);
|
||||
UpdateIndex();
|
||||
}
|
||||
|
||||
private void textBox2_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
Data.m = Convert.ToDouble(textBox2.Text)/100;
|
||||
UpdateIndex();
|
||||
}
|
||||
|
||||
public void UpdateIndex()
|
||||
{
|
||||
if (Data.index != null && Data.m != null)
|
||||
{
|
||||
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 >= 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user