VS复习 -- if···else和if···else嵌套语句

注意:理清逻辑,画出逻辑分支图,理清思路

1.if语句

2.if...else语句

3.if..else if...else

 1 static void Main(string[] args)
 2         {
 3             Console.WriteLine("输入分数:");
 4 
 5             string fs = Console.ReadLine();
 6             int score = Convert.ToInt32(fs);
 7 
 8             #region  判断分数
 9             if (score >= 0 && score < 60)
10             {
11                 Console.WriteLine("不及格,补考");
12             }
13             else if (score >= 60 && score < 80)
14             {
15                 Console.WriteLine("恭喜及格");
16             }
17             else if (score >= 80 && score <= 100)
18             {
19                 Console.WriteLine("恭喜优秀");
20             }
21             else
22             {
23                 Console.WriteLine("输入有误");
24             }
25             #endregion
26             
27             Console.WriteLine("结束");
28         }

3.输入分数,如果小于60,再判断加分项,然后输出是否及格

 1  static void Main(string[] args)
 2         {
 3             Console.WriteLine("输入分数:");
 4 
 5             string fs = Console.ReadLine();
 6             int score = Convert.ToInt32(fs);
 7 
 8             if (score < 60)
 9             {
10                 Console.WriteLine("是否认真做作业?(是,否)");
11 
12                 string zuoye = Console.ReadLine();
13 
14                 #region ======加分=======
15                 if (zuoye == "")
16                 {
17                     score = score + 5;
18 
19                     if (score < 60)
20                     {
21                         Console.WriteLine("不及格");
22                     }
23                     else
24                     {
25                         Console.WriteLine("凑合及格");
26                     }
27                 }
28                 else
29                 {
30                     Console.WriteLine("不及格了");
31                 }
32                 #endregion
33             }
34             else
35             {
36 
37             }
38 
39             Console.WriteLine("结束");
40         }

 

转载于:https://www.cnblogs.com/kellybutterfly/p/5399607.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值