c#编程 输入某人体重身高,按一下标准判定:是否为标准 过胖 过瘦
答案:1 悬赏:20 手机版
解决时间 2021-04-04 15:56
- 提问者网友:温旧梦泪无声
- 2021-04-03 19:29
c#编程 输入某人体重身高,按一下标准判定:是否为标准 过胖 过瘦
最佳答案
- 五星知识达人网友:野味小生
- 2021-04-03 20:09
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 )
{
MessageBox.Show ( "您的体型偏瘦!" );
}
else
{
MessageBox.Show ( "您的体型完全正常!" );
}
}
else
{
MessageBox.Show ( "体重必须是介于 5KG到 300KG之间的整数!" );
}
}
else
{
MessageBox.Show ( "身高必须是介于 30CM到 250CM之间的整数!" );
}
}
{
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 )
{
MessageBox.Show ( "您的体型偏瘦!" );
}
else
{
MessageBox.Show ( "您的体型完全正常!" );
}
}
else
{
MessageBox.Show ( "体重必须是介于 5KG到 300KG之间的整数!" );
}
}
else
{
MessageBox.Show ( "身高必须是介于 30CM到 250CM之间的整数!" );
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯