作業(yè)要求:讓用戶輸入姓名 語(yǔ)文 數(shù)學(xué) 英語(yǔ) 三門課的成績(jī),然后給用戶顯示:XX,你的總成績(jī)?yōu)閄X分宠哄,平均成績(jī)?yōu)閄X分
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("請(qǐng)輸入您的名字");//輸入名字
string strname = Console.ReadLine();
Console.WriteLine("請(qǐng)先輸入您的語(yǔ)文成績(jī)");//輸入語(yǔ)文成績(jī)
string strChinese = Console.ReadLine();
Console.WriteLine("請(qǐng)?jiān)佥斎肽臄?shù)學(xué)成績(jī)");//輸入數(shù)學(xué)成績(jī)
string strmath = Console.ReadLine();
Console.WriteLine("最后輸入您的英語(yǔ)成績(jī)");//輸入英語(yǔ)成績(jī)
string strEnglish = Console.ReadLine();
int Chinese = Convert.ToInt32(strChinese);//將字符串型數(shù)值轉(zhuǎn)換成整型數(shù)值
int math = Convert.ToInt32(strmath);
int English = Convert.ToInt32(strEnglish);
Console.WriteLine("{0}员串,你的總成績(jī)?yōu)閧1}分,平均分為{2}分", strname,Chinese+math+English,(Chinese+math+English)/3);//輸出總成績(jī)和平均分
Console.ReadKey();
}
}
}