try
{
Console.WriteLine("请输入本月消费记录");
//1、声明和分配空间
double[] money = new double[5];
// 2、赋值
for (int i = 0; i < money.Length; i++)
{
Console.Write("请输入第{0}笔购物金额:", i + 1);
money[i] = Convert.ToInt32(Console.ReadLine());
}
double sum = 0;
//3 使用
Console.WriteLine("序号\t\t\t\t金额(元)");
for (int i = 0; i < money.Length; i++)
{
sum += money[i];
Console.WriteLine(" {0}\t\t\t\t{1}", i + 1, money[i]);
}
//输入平均成绩
Console.WriteLine("总金额\t\t\t\t{0}", sum);
if (sum <10000)
{
Console.WriteLine("穷比月消费都没有10000");
}
else if(sum>=10000)
{
Console.WriteLine("老板真有钱");
}
}
catch
{
Console.WriteLine("你输入的格式错误");
}
Console.ReadKey();
网友评论