购物金额结算
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.ToDouble(Console.ReadLine());
sum += a[i];
}
Console.WriteLine("\n");
Console.WriteLine("序号\t\t金额(元)");
for (int i = 0; i < a.Length; i++)
{
Console.WriteLine("{0}\t\t{1}", i + 1, a[i]);
}
Console.WriteLine("总金额t\t\t56{0}", sum);
}
catch
{
Console.WriteLine("输入有误!");
}
Console.ReadKey();
QQ图片20181206104616.png
网友评论