zoukankan      html  css  js  c++  java
  • C#学习7.31判断体重是否超标

    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();

           

               }    

         }

    }

  • 相关阅读:
    绿色版 notepad++ 添加鼠标右键菜单
    Scala 安装与配置
    Scala 神奇的下划线 _
    Kafka 安装部署
    Pulsar 下一代消息平台
    Sqoop 安装部署
    Flume 常用配置项
    Android-selector
    android- 9patch
    有关内存的思考题
  • 原文地址:https://www.cnblogs.com/xiaobao5161/p/5723305.html
Copyright © 2011-2022 走看看