代码
try
{
double[] money = new double[5];double sum =0;
Console.WriteLine("请输入会员本月的消费记录");
for (int i = 0; i < money.Length; i++)
{
Console.Write("请输入第{0}笔购物金额:",i +1);
money [i] = Convert.ToDouble (Console .ReadLine ());
sum += money [i];
}
Console.WriteLine();
Console.WriteLine("序号" + "\t"+ "金额(元)");
for (int i = 0; i < money.Length; i++)
{
Console.WriteLine("{0}"+"\t"+"{1}",i+1,money [0]);
}
Console.WriteLine("总金额"+"\t"+"{0}",sum);
}
catch
{
Console.WriteLine("您输入的格式有误!");
}
Console.ReadKey();
效果