c#编程 输入某人体重身高,按一下标准判定:是否为标准 过胖 过瘦

来源:百度知道 编辑:UC知道 时间:2024/05/03 23:43:07
(1)标准体重=(身高-110)kg
(2)超过标准体重5kg为过胖
(3)低于标准体重5kg为过瘦

private void button1_Click ( object sender, EventArgs e )
{
string strHeight = textBox1.Text.Trim ( );
string strWeight = this.textBox2.Text.Trim ( );

int Height = 0;
bool IsInteger = int.TryParse ( strHeight, out Height );

if ( IsInteger && ( Height > 30 && Height <= 250 ) )
{
int Weight = 0;
IsInteger = int.TryParse ( strWeight, out Weight );
if ( IsInteger && ( Weight > 5 && Weight < 300 ) )
{
int StandartWeight = Height - 110;

if ( Weight - StandartWeight > 5 )
{
MessageBox.Show ( "您的体形偏胖!" );
}
else if ( StandartWeight - Weight > 5 )
{