第十节课第二个作业
十节课二try
{
int[] jinge = new int[5];
int sum = 0;
Console.WriteLine("请输入5位学员的金额");
for (int i = 0; i < jinge.Length; i++)
{
Console.Write("第{0}位的金额是:",i +1);
jinge[i] = Convert.ToInt32(Console.ReadLine());
sum = sum + jinge[i];
}
Console.WriteLine("序号 金额(元)");
for (int i = 0; i < jinge.Length; i++)
{
Console.WriteLine("{0} {1}" ,i +1,jinge[i ] );
}
Console.WriteLine ("总金额 {0}", sum);
}
catch
{
Console.WriteLine("输入格式错误");
}
Console.ReadKey();
网友评论