2018-12-05第二题

效果

2018-12-05第二题_第1张图片
图片发自App


代码

double[] myarr = new double[5];

double zg = 0;

Console.WriteLine("请输入会员本日的消费记录");

try

{

for (int i = 0; i < myarr.Length; i++)

{

Console.Write("请输入第{0}笔购物金额:", i+1);

myarr[i] = Convert.ToInt32(Console.ReadLine());

zg += myarr[i];

}

Console.WriteLine("序号 金额(元)");

for (int i = 0; i < myarr.Length; i++)

{

Console.WriteLine("{0} {1}", i + 1, myarr[i]);

}

Console.WriteLine("总金额 {0}", zg);

}

catch

{

Console.WriteLine("输入格式错误");

}

Console.ReadKey();

你可能感兴趣的:(2018-12-05第二题)