namespace ConsoleApplication30 { class Program { struct buy { public string name; public double prc; public int shul; } static void Main(string[] args) { ArrayList al = new ArrayList(); double sum = 0; while (true) { buy b = new buy(); Console.Write("BANDAI官方旗舰店欢迎您!" + " " + "请输入您选择的商品:"); b.name = Console.ReadLine(); Console.Write("请输入你要商品的价格(/元):"); b.prc = Convert.ToDouble(Console.ReadLine()); Console.Write("请输入你要商品的数量(/个):"); b.shul = Convert.ToInt32(Console.ReadLine()); al.Add(b);//结构体b累计到集合中 Console.Write("请问是否结账:Y/N:"); string d = Console.ReadLine(); if (d.ToUpper()=="Y") { break; } else { } } for (int i = 0; i < al.Count; i++) { sum = sum + ((buy)al[i]).prc * ((buy)al[i]).shul;//累计花了多少钱 } if (sum>=100&&sum<=200) { Console.WriteLine("您这次总共花销为"+sum+" 折扣为9.5折 实际花销为"+(sum*0.95)+"元 节省了"+(sum*0.05)+"元"); } else if (sum > 200 && sum <= 300) { Console.WriteLine("您这次总共花销为" + sum + " 折扣为9折 实际花销为" + (sum * 0.90) + "元 节省了" + (sum * 0.1) + "元"); } else if (sum >300 && sum <= 400) { Console.WriteLine("您这次总共花销为" + sum + " 折扣为8.5折 实际花销为" + (sum * 0.85) + "元 节省了" + (sum * 0.15) + "元"); } else if (sum>0&&sum<100) { Console.WriteLine("您这次总共花销为" + sum + " 无折"); } else { Console.WriteLine("您这次总共花销为" + sum + " 折扣为8折 实际花销为" + (sum * 0.8) + "元 节省了" + (sum * 0.2) + "元"); } Console.ReadLine(); } } }