美文网首页
2018-10-25

2018-10-25

作者: 晨颜 | 来源:发表于2018-10-25 11:12 被阅读0次

    作业1

    计算半径为5的圆的面积和周长并打印出来。(pi为3.14)面积:pi*r*r;Perimeter(周长);

    代码:

    //计算半径为5的圆的面积和周长并打印出来。(pi为3.14)面积:pi*r*r;Perimeter(周长);

    int r = 5; double pi = 3.14; double s = pi * r * r; double Perimeter = 2 * pi * r; Console.WriteLine("半径为5的圆的面积为{0},周长为{1}",s, Perimeter); Console.ReadKey();

    运行效果

    作业2(1)

    用户输入姓名 语数英三门成绩,然后给用户显示:XX,您的总成绩为XX分,平均成绩为XX分

    代码

    //用户输入姓名 语数英三门成绩,然后给用户显示:XX,您的总成绩为XX分,平均成绩为XX分;

    Console.WriteLine("请输入您的姓名");

    string strXingming = Console.ReadLine();

    Console.WriteLine("请输入您的语文成绩");

    string strChinese = Console.ReadLine();

    Console.WriteLine("请输入您的数学成绩");

    string strMath = Console.ReadLine();

    Console.WriteLine("请输入您的英语成绩");

    string strEnglish = Console.ReadLine();

    int Chinese = Convert.ToInt32(strChinese);

    int Math = Convert.ToInt32(strMath);

    int English = Convert.ToInt32(strEnglish);

    int zongfen = Chinese + Math + English;

    double pingjunfen = zongfen / 3.0;

    Console.WriteLine("{0},您的总成绩为{1}分,平均成绩为{2}分",strXingming, zongfen, pingjunfen);

    Console.ReadKey();

    运行效果

    作业2(2)

    代码

    //用户输入天数,计算这个天数是几周零几天

                Console.WriteLine("请输入天数");

                string strtianshu = Console.ReadLine();

                int tianshu = Convert.ToInt32(strtianshu);

                int zhou = tianshu / 7;int tian = tianshu % 7;

                Console.WriteLine("{0}天是{1}周零{2}天",strtianshu,zhou,tian);

                Console.ReadKey();

    运行效果

    相关文章

      网友评论

          本文标题:2018-10-25

          本文链接:https://www.haomeiwen.com/subject/akeqtqtx.html