//Declarations
double height;
double weight;
double BMI;
int Const;
//Reading User Input
//HEIGHT
Console.WriteLine("Please enter the person's height in inches: ");
height = Convert.ToDouble(Console.ReadLine());
if (height < 5 && height > 120)
{
Console.WriteLine("The height entered must be between 5” and 120” inclusive.");
}
//MASS
Console.WriteLine("Please enter the person's weight in lbs: ");
weight = Convert.ToDouble(Console.ReadLine());
if (weight < 0.5 && weight > 999)
{
Console.WriteLine("The weight entered must be between 0.5 lb. and 999 lb. inclusive.");
}
//BMI Calculations
Const = 703;
BMI = (weight/(height * height)) * Const;
//Category Assignments
if (BMI <= 16)
{
Console.WriteLine("The BMI for a " + height + "tall person who weighs " + weight + " lb. is 26.7, which is categorized as 'serverly underwieght'.");
}
else if (BMI > 16 && BMI <= 18.5)
{
Console.WriteLine("The BMI for a " + height + "tall person who weighs " + weight + " lb. is 26.7, which is categorized as 'underwieght'.");
}
else if (BMI > 18.5 && BMI <= 25)
{
Console.WriteLine("The BMI for a " + height + "tall person who weighs " + weight + " lb. is 26.7, which is categorized as 'healthy'.");
}
else if (BMI > 25 && BMI < -30)
{
Console.WriteLine("The BMI for a " + height + "tall person who weighs " + weight + " lb. is 26.7, which is categorized as 'Overweight'.");
}
else if (BMI > 30)
{
Console.WriteLine("The BMI for a " + height + "tall person who weighs " + weight + " lb. is 26.7, which is categorized as 'Obese'.");
}
}
}
}
第一个问题在这里,所以抱歉不正确的格式。无论如何,我的计划在我进入体重后立即关闭,就像瞬间。它的控制台应用程序btw。我的程序似乎没有按照我的如果语句
此外,如果我输入的重量或高度低于或高于要求,它不显示错误消息,只是继续然后关闭。
这是学习使用调试器的好时机。它将允许您一次完成一行,准确查看发生了什么。 –