作業(yè)要求
讓用戶輸入他的語文和數(shù)學成績,計算他的總成績并顯示出來。
代碼
...
namespace _2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("");
Console.WriteLine("請先輸入你的姓名");
Console.WriteLine("");
string name=Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("請輸入你的語文成績");
Console.WriteLine("");
string strChinese = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("請輸入你的數(shù)學成績");
Console.WriteLine("");
string strMath = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("請輸入你的英語成績");
Console.WriteLine("");
string strEnglish = Console.ReadLine();
Console.WriteLine("");
int chinese = Convert.ToInt32(strChinese);
int math = Convert.ToInt32(strMath);
int english = Convert.ToInt32(strEnglish);
int sum = chinese + math + english;
double pj = sum / 3.0;
Console.WriteLine("您好,{0},你的總分是{1},平均分是{2}",name,sum,pj);
Console.ReadKey();
}
}
}
...
效果

圖片發(fā)自簡書App