Reputation: 59
I'm trying to have the user enter their information, and the program will take the info and find your BMI. I'm having trouble with my equation and if statement. I can't seem to find where my issue is.
double _bmi = (_poundsVal / (_inchesVal * _heightVal)) * 703;
if (_bmi <= 18.5)
{
Console.WriteLine("Your BMI is" + _bmi.ToString() + "you are considered underweight");
}
else if (_bmi > 18.5 && _bmi <= 24.9)
{
Console.WriteLine("Your BMI is " + _bmi.ToString() + "you are considered normal weight");
}
else if (_bmi <= 25 && _bmi <= 29.9)
{
Console.WriteLine("Your BMI is" + _bmi.ToString() + "you are considered overweight");
}
else
{
Console.WriteLine("Your BMI is" + _bmi.ToString() + "you are considered obese");
}
Upvotes: 0
Views: 475
Reputation: 34152
_bmi should be a double
not an int
. change this line:
int _bmi = (_poundsVal / (_inchesVal * _heightVal)) * 703;
to
double _bmi = (_poundsVal / (_inchesVal * _heightVal)) * 703;
secondly as _bmi is a double, you don't need to Parse it, so remove this if and just keep its content:
if (double.TryParse(_bmi, out _bmiVal))
Upvotes: 1