c#04流程控制语句

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _04
{
class Program
{
static void Main(string[] args)
{
// 1.小强参加Java考试,爸爸答应他如下条件:(多重if)
// 成绩 >= 90 :送奔驰轿车
// 成绩 >= 80 :送奥迪轿车
// 成绩 >= 60 :送比亚迪F0
// 成绩 < 60 :送一个耳光

        //Console.WriteLine("请输入小强的考试成绩:");
        //int a = int.Parse(Console.ReadLine());
        //if (a >= 90)
        //    Console.WriteLine("送奔驰轿车");
        //else if (a >= 80)
        //    Console.WriteLine("送奥迪轿车");
        //else if (a >= 60)
        //    Console.WriteLine("送比亚迪F0");
        //else
        //    Console.WriteLine("送一个耳光");
        //Console.ReadLine();

        //2.机票预定:实际机票价格 原价为4000元(嵌套if)
        //    5 - 10月为旺季,头等舱打9折,经济舱打7.5折
        //    其余时间为淡季,头等舱打6折,经济舱打3折

        //Console.WriteLine("请输入季节:");
        //int a = int.Parse(Console.ReadLine());
        //Console.WriteLine("买头等舱输入1,经济舱输入2");
        //int b = int.Parse(Console.ReadLine());
        //if (a > 4 && a < 11)
        //{
        //    Console.WriteLine(b == 1 ? 4000 * 0.9 : 4000 * 0.75);
        //}
        //else
        //{
        //    Console.WriteLine(b == 1 ? 4000 * 0.6 : 4000 * 0.3);
        //}
        //Console.ReadLine();
        //3.输入一个月份, 打印出该月的天数(switch)
        //  月份: 4,6,9,11 小月 1,3,5,7,8,10,12 大月
        //Console.WriteLine("请输入一个月份:");
        //switch (Console.ReadLine())
        //{
        //    case "1":
        //    case "3":
        //    case "5":
        //    case "7":
        //    case "8":
        //    case "10":
        //    case "12":
        //        Console.WriteLine("31");
        //        break;
        //    default:
        //        Console.WriteLine("30");
        //        break;
        //}
        //Console.ReadLine();
        //4.循环输出10到100之间所有能被5整除的数(while)。
        //int a = 10;
        //while (a < 101)
        //{
        //    if (a % 5 == 0)
        //        Console.WriteLine(a);
        //    a++;
        //}
        //Console.ReadLine();
        //5.计算1 + 2 + 3 +……+100的结果(do...while)
        //int a = 1;
        //int sum = 0;
        //do
        //{
        //    sum += a;
        //    a++;
        //} while (a < 101);
        //Console.WriteLine(sum);
        //Console.ReadLine();
        //6.从1一直加到100,但如果累加的和大于500也要结束循环,
        //并输出此时已经加到的数是什么(for)
        //int sum = 0;
        //for (int i = 1; i < 101; i++)
        //{
        //    sum += i;
        //    if (sum >= 500)
        //    {
        //        Console.WriteLine(sum);
        //        Console.ReadLine();
        //        break;
        //    }
        //}


    }
}

}

猜你喜欢

转载自blog.csdn.net/lxq5211314/article/details/82502683