#作業(yè)要求
輸入班級人數(shù),然后依次輸入學(xué)員成績,計(jì)算班級學(xué)員的平均成績和總成績
#程序
namespace ConsoleApplication1
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? Console.WriteLine("請輸入班級人數(shù)");
? ? ? ? ? ? int a = Convert.ToInt32(Console.ReadLine());
? ? ? ? ? ? int i = 1;
? ? ? ? ? ? int sum = 0;
? ? ? ? ? ? while (i <=a)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Console.WriteLine("請輸入第{0}位同學(xué)的成績", i);
? ? ? ? ? ? ? ? try
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? int b = Convert.ToInt32(Console.ReadLine());
? ? ? ? ? ? ? ? ? ? sum = sum + b;
? ? ? ? ? ? ? ? ? ? i++;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? catch
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? Console.WriteLine("輸入有誤台诗,請重新輸入");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? Console.WriteLine("該班共有{0}人棠众,總成績?yōu)閧1},平均成績是{2}", a, sum,sum/a);
? ? ? ? ? ? Console.ReadKey();
? ? ? ? }
? ? }
}