美文网首页
第三次作业第二题

第三次作业第二题

作者: 孤独是种安全感_b7bf | 来源:发表于2018-10-25 15:54 被阅读0次

    第一小题

    代码

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

    namespace 第三次作业第二题
    {
    class Program
    {
    static void Main(string[] args)
    {
    /**
    * 让用户输入姓名 语文 数学 英语三门课的成绩
    * 然后显示:xx,你的总成绩为xx分,平均成绩为xx分
    *
    *
    * */
    //输入姓名 语文 数学 英语 成绩
    Console.WriteLine("请输入你的姓名");
    string strname = 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 totoal = chinese + math + english;
            int ave = totoal / 3;
            //输出
            Console.WriteLine("{0},你的总成绩为{1}分,平均成绩为{2}",strname,totoal,ave);
            Console.ReadKey();
    
        }
    }
    

    }

    效果

    IMG_20181025_092018.jpg

    代码

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

    namespace 第三次作业第二第二小题
    {
    class Program
    {
    static void Main(string[] args)
    {

            /**
             * 让用户输入天数,并计算这个天数是几周零几天,比如四十六天是6周零4天
             * 
             * 
             * */
            //输入天数
            Console.WriteLine("请输入天数");
            string strday = Console.ReadLine();
            //将字符型数字转换成数值型数字
            int day = Convert.ToInt32 (strday);
            int week = day / 7;
            int day1 = day % 7;
            //输出
    
            Console.WriteLine("{0}是{1}周零{2}天",day,week,day1);
            Console.ReadKey();
    
    
        }
    }
    

    }

    效果

    IMG_20181025_094236.jpg

    相关文章

      网友评论

          本文标题:第三次作业第二题

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