作业4.称体重

男人的标准体重是:体重(kg)=身高(cm)-100。
女人的标准体重是:体重(kg)=身高(cm)-110。
上下浮动3公斤属正常
要求输入性别、身高和体重,输出正常,偏胖,偏瘦

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 
 6 namespace ConsoleApplication1
 7 {
 8     class 体重
 9     {
10         static void Main(string[] agre)
11         {
12             Console.Write("请输入你的性别(男,女):");
13             string sex = Console.ReadLine();
14             Console.Write("请输入你的身高(cm):");
15             string h = Console.ReadLine();
16             int high = Convert.ToInt32(h);
17             Console.Write("请输入你的体重(KG):");
18             string m = Console.ReadLine();
19             int t = Convert.ToInt32(m);
20 
21             if (sex == "")
22             {
23                 if (t > high - 100 + 3) 
24                 {
25                     Console.WriteLine("你的体重偏胖。");
26                 }
27                 else if (t < high - 100 - 3)
28                 {
29                     Console.WriteLine("你的体重偏瘦。");
30                 }
31                 else if (t >=high - 100 -3&& t<= high -100 +3)
32                 {
33                     Console.WriteLine("你的体重正常");
34                 }
35             }
36             else if (sex == "")
37             {
38                 if (t > high - 110 + 3)
39                 {
40                     Console.WriteLine("你的体重偏胖。");
41                 }
42                 else if (t < high - 110 - 3)
43                 {
44                     Console.WriteLine("你的体重偏瘦。");
45                 }
46                 else
47                 {
48                     Console.WriteLine("你的体重正常");
49                 }
50             }
51             else
52             {
53                 Console.WriteLine("输入的不正确,请核实。");
54             }
55         }
56     }
57 }

 

posted on 2014-12-22 21:02  酸甜sky  阅读(205)  评论(0编辑  收藏  举报