try
{
double[] a = new double[5];
double sum = 0;
Console.WriteLine("请输入会员本月的消费记录");
for (int i = 0; i < a.Length; i++)
{
Console.Write("请输入第{0}笔消费金额:", i + 1);
a[i] = Convert.ToInt32(Console.ReadLine());
sum += a[i];
}
Console.WriteLine("/n");
Console.WriteLine("序号 金额(元)");
for (int i = 0; i < a.Length; i++)
{
Console.Write("{0} {1}", i + 1, a[i]);
}
Console.Write("总金额 {0}", sum);
}
catch
{
Console.WriteLine("输入有误!");
}
Console.ReadKey();
网友评论