using System;
using System.Collections.Generic;
using System.Linq; using System.Text;
using System.Threading.Tasks;
namespace 练习1
{
//要求写一个函数判断体重是否超标
//函数具有三个参数,分别是性别、体重(Kg)、身高(cm)
//辨别方法:“男” 身高-100=体重+/-3 ;“女” 身高-110=体重+/-3
class Program
{
public string celing(string sex,int heavy ,int hight)
{
if (sex == "男")
{
if (hight - 100 == heavy + 3 || hight - 100 == heavy - 3)
{
return "您的体重标准!";
}
else
{
return "您的体重不达标!";
}
}
else if (sex == "女")
{
if (hight - 110 == heavy + 3 || hight - 110 == heavy - 3)
{
return "您的体重标准!";
}
else
{
return "您的体重不达标!";
}
}
else
return "您的输入有误,请重试!";
}
static void Main(string[] args)
{
Console.Write("请输入您的性别:");
string sex = Console.ReadLine();
Console.Write("请输入您的体重:请用Kg表示)");
int heavy = int.Parse(Console.ReadLine());
Console.Write("请输入您的身高:(请用cm表示)");
int hight = int.Parse(Console.ReadLine());
Console.WriteLine("输入完毕请按回车键打印!");
Console.ReadLine();
Program hanshu = new Program();
Console.Write("您的性别是:{0},体重{1}Kg,身高{2}cm,",sex ,heavy ,hight );
Console.WriteLine(hanshu.celing(sex,heavy ,hight ));
Console.ReadLine();
}
}
}