namespace 商场打折结构体
{
class Program
{
struct ZhuangBei
{
public string name;
public double price;
public int amount;
}
static void Main(string[] args)
{
while (true)
{
Console.WriteLine("\t\t**********约里克超神店欢迎您的光临**********");
double sum = 0;
ArrayList al = new ArrayList();
ZhuangBei a = new ZhuangBei();
while (true)
{
Console.WriteLine("请输入您要购买的物品名称:");
a.name = Console.ReadLine();
Console.WriteLine("请输入单价:");
a.price = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入数量:");
a.amount = Convert.ToInt32(Console.ReadLine());
al.Add(a);
Console.WriteLine("您是否需要结账(Y/N)");
string x = Console.ReadLine();
if (x == "Y")
{
break;
}
} //第二个while的花括号
for (int i = 0; i < al.Count; i++)
{
sum =sum+ ((ZhuangBei)al[i]).price * ((ZhuangBei)al[i]).amount;
}
if (sum < 3000)
{
sum = sum * 1;
}
if(sum>3000&&sum<=4000)
{
sum = sum * 0.9;
}
if (sum > 4000 )
{
sum = sum * 0.8;
}
Console.WriteLine("折后价:"+sum);
Console.WriteLine("欢迎再次光临");
} //第一个while的花括号
}
}
}