作業(yè)要求
讓用戶輸入姓名 語文 數(shù)學(xué) 英語 三門課的成績,然后給用戶顯示:XX,你的總成績?yōu)閄X分,平均成績?yōu)閄X分
代碼
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("再輸入您的數(shù)學(xué)成績");
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},你的總成績?yōu)閧1}分,平均成績?yōu)閧2}分", name, total, pj);
Console.ReadKey();
效果

圖片發(fā)自簡書App