Posted on March 25, 2010.
Help programming class = expected? I am building a calculator a bit more complicated BMI and received the message errror "Expected class, delegate, enum, interface or struct"
is the code I wrote
(
double height = Convert.ToDouble (TextBox1.Text);
double weight = Convert.ToDouble (TextBox2.Text);
double BMI = weight / (height * height);
if (BMI> = 27.5)
(
MessageBox.Show ("Warning, you have a high risk of heart disease and diabetes");
)
else
(If (BMI> = 23 & & <BMI = 27.4)
(
MessageBox.Show ("You have a moderate risk of heart disease and diabetes");
)
else
(If (BMI> = 18.5 & & <BMI = 22.9)
(
MessageBox.Show ("Congratulations, you're on the range in good health");
)
else
MessageBox.Show ("You risk deficiency diseases and osteoporosis");
)
)
)
Hello -
You write in Visual C + +, right?
Well, the code seems correct, but where did you "write" what is it? I suppose you've written for the "code" of your form, but you miss namespace header that defines this code as a reference to your form. It should look like this:
WHATEVER namespace (
double height = Convert.ToDouble (TextBox1.Text ...
double weight = Convert.ToDouble (TextBox2.Text ...
double BMI = weight / (height * height);
if (BMI> = 27.5)
(
MessageBox.Show ("Warning, you have a high risk of heart disease and diabetes");
)
else
(If (BMI> = 23 & & <BMI = 27.4)
(
MessageBox.Show ("You have a moderate risk of heart disease and diabetes");
)
else
(If (BMI> = 18.5 & & <BMI = 22.9)
(
MessageBox.Show ("Congratulatio ... you are on the range in good health");
)
else
MessageBox.Show ("You risk deficiency diseases and osteoporosis");
)
)
)
I hope that helps?
Fly