C#作业7

作业要求

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

代码

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

namespace ConsoleApplication2
{
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 pj = total / 3;

        Console.WriteLine("您好,{0},你的总成绩为{1}分,平均成绩为{2}分", name, total, pj);

        Console.ReadKey();

效果

图片发自简书App
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容