zoukankan      html  css  js  c++  java
  • 商场打折结构体

    namespace 商场打折结构体
    {
        class Program
        {
            struct ZhuangBei
            {
                public string name;
                public double price;
                public int amount;
           
            }
            static void Main(string[] args)
            {
                while (true)
                {
                    Console.WriteLine(" **********约里克超神店欢迎您的光临**********");
                    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的花括号
            }
        }
    }

  • 相关阅读:
    谈谈php依赖注入和控制反转
    关于php 高并发解决的一点思路
    php常用的优化手段
    php判断多维数组的技巧
    浅谈echo、print、var_dump()、print_r()的区别
    MYSQL表记录字段换行符回车符处理
    mysqldumpslow的使用简介
    mysql性能优化配置总结
    关闭discuzX3.2注册页面的注册邮箱验证
    php变量布尔值验证
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4415467.html
Copyright © 2011-2022 走看看