首页 > 其他 > 详细

作业4.称体重

时间:2014-12-22 22:34:23      阅读:352      评论:0      收藏:0      [点我收藏+]

男人的标准体重是:体重(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 }

 

作业4.称体重

原文:http://www.cnblogs.com/viven/p/4178968.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!