第九课

以表格的形式输出5笔购物金额及总金额
try
{
Console.WriteLine("请输入会员本月的消费记录:");
string[] money = new string[5];
for (int i = 0; i < money.Length; i++)
{
Console.WriteLine ("请输入第{0}个购物金额:",i+1);
money[i] =(i+1 +" " + Console .ReadLine ());
}

Console.WriteLine ("序号 金额(元)");
foreach (var item in money)
{
Console.WriteLine(item);
}
}
catch {
Console.WriteLine ("程序错误");
}
Console.ReadKey();

你可能感兴趣的:(第九课)