題目
讓用戶輸入姓名 語文 數(shù)學 英語 三門課的成績嗅剖,然后給用戶顯示:XX,您的總成績?yōu)閄X分嘁扼,平均成績?yōu)閄分
代碼
Console.WriteLine("請輸入你的姓名");
string strname=Console.ReadLine();
string name = Convert.ToString(strname);
Console.WriteLine("請輸入你的語文成績");
string strchinese = Console.ReadLine();
int chinese = Convert.ToInt32(strchinese);
Console.WriteLine("請輸入你的數(shù)學成績");
string strmath = Console.ReadLine();
int math = Convert.ToInt32(strmath);
Console.WriteLine("請輸入你的英語成績");
string strenglish = Console.ReadLine();
int english = Convert.ToInt32(strenglish);
int sum = chinese + math + english;
int qingjunfen = sum / 3;
Console.WriteLine("你的總成績?yōu)閧0}分信粮,平均成績?yōu)閧1}",sum, qingjunfen );
Console.ReadKey();
效果圖
image.png