题目
从键盘输入学生姓名及其5门课成绩(语文,数学,英语,物理,化学),输出5门课的总成绩及平均分。
方法比较笨,首先定义变量(字符串,整数),然后写输入,在相加,然后在除五得平均分。
string x;
int y,s,yen,w,h;
Console.Write("请输入姓名:");
x = Console.ReadLine();
Console.Write("请输入语文成绩:");
y = Convert.ToInt16(Console.ReadLine());
Console.Write("请输入数学成绩:");
s = Convert.ToInt16(Console.ReadLine());
Console.Write("请输入英语成绩:");
yen = Convert.ToInt16(Console.ReadLine());
Console.Write("请输入物理成绩:");
w = Convert.ToInt16(Console.ReadLine());
Console.Write("请输入化学成绩:");
h = Convert.ToInt16(Console.ReadLine());
int z = y+s+yen+w+h;
int p = z / 5;
Console.WriteLine("姓名:{0}",x);
Console.WriteLine("总成绩:{0}",z);
Console.WriteLine("平均成绩:{0}",p);