美文网首页
#笔记3-1

#笔记3-1

作者: 八度_八度 | 来源:发表于2018-10-25 09:40 被阅读0次


#作业要求:

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

#代码:

namespace 作业2

{

    class Program

    {

        static void Main(string[] args)

        {

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

            string name = 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 total = chinese + math + English;

            double avg=total /3;

            Console.WriteLine("你的名字是{0},总分是{1},平均分是{2}",name ,total ,avg );

            Console.ReadKey();

        }

    }

}

#效果:

 

#笔记3-1

相关文章

网友评论

      本文标题:#笔记3-1

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