//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。我的程序似乎沒有按照我的如果語句
此外,如果我輸入的重量或高度低於或高於要求,它不顯示錯誤消息,只是繼續然後關閉。
這是學習使用調試器的好時機。它將允許您一次完成一行,準確查看發生了什麼。 –