can someone help me to get the right answer when radio button metric is checked i get the write bmr from height (cm )and weight (kg) but when imperial US button is checked i am not able to get the right answer, For the Imperial option , given in feet (ft) and inches (in) and weight is in pounds (lb).
note : BMR = 10 * weight (kg) + 6.25 * height (cm) - 5 * age (y I tried this code but did not work for me
any help would be appreciated Thanks in advance
i know my code is a mess but i am just a beginner
What I have tried:
private bool InputBMR()
{
{
if (BmrCalc.GetUnit() == UnitTypes.Us)
if
(int.TryParse(txtAge.Text, out var age) &&
double.TryParse(txtHeightInch.Text, out var height) &&
double.TryParse(txtWeight.Text, out var weight))
{
double num1, num2, result;
num1 = Convert.ToDouble(txtheightIFeet.Text);
num2 = Convert.ToDouble(txtHeightInch.Text);
result = (num2 + (num1 * 12));
BmrCalc.Age = age;
BmrCalc.Height = result;
BmrCalc.Weight = weight;
return true;
}
else
{
MessageBox.Show("Error: Invalid input in bmr calculator. ", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
if(rdoMetric.Checked)
if(int.TryParse(txtAge.Text, out var age) &&
double.TryParse(txtHeightInch.Text, out var height) &&
double.TryParse(txtWeight.Text, out var weight))
{
BmrCalc.Age = age;
BmrCalc.Height = height;
BmrCalc.Weight = weight;
return true;
}
else
{
MessageBox.Show("Error: Invalid input in Bmi calculator. Height must be numbers ", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
return true;
}