陈锋裕作业

product={} product["001"]={"Name":"美式面包","Unit":"个","Price":10.00,"Class":"西点类","integral":10.00}
product["002"]={"Name":"法式面包","Unit":"个","Price":15.00,"Class":"西点类","integral":15.00}
product["003"]={"Name":"日食面包","Unit":"个","Price":8.00,"Class":"西点类","integral":8.00}
product["004"]={"Name":"法国啤酒","Unit":"瓶","Price":20.00,"Class":"酒类","integral":20.00}
product["005"]={"Name":"巴西扎啤","Unit":"听","Price":12.00,"Class":"酒类","integral":12.00}
product["007"]={"Name":"国窖100ml","Unit":"瓶","Price":98.00,"Class":"酒类","integral":98.00}
product["009"]={"Name":"美国红苹果","Unit":"Kg","Price":18.00,"Class":"水果类","integral":18.00}
product["010"]={"Name":"日本红富士","Unit":"Kg","Price":12.00,"Class":"水果类","integral":12.00}
product["012"]={"Name":"菲律宾香蕉","Unit":"Kg","Price":9.80,"Class":"水果类","integral":9.80}
product["013"]={"Name":"大白菜","Unit":"Kg","Price":6.00,"Class":"蔬菜类","integral":6.00}
product["014"]={"Name":"黄瓜","Unit":"Kg","Price":5.60,"Class":"蔬菜类","integral":5.60}
product["015"]={"Name":"西兰花","Unit":"Kg","Price":10.00,"Class":"蔬菜类","integral":10.00}
product["016"]={"Name":"大黄鱼","Unit":"Kg","Price":80.00,"Class":"海鲜类","integral":80.00}
product["017"]={"Name":"黄刺鱼","Unit":"Kg","Price":50.00,"Class":"海鲜类","integral":50.00}
product["018"]={"Name":"带鱼","Unit":"Kg","Price":6.00,"Class":"海鲜类","integral":6.00}
 
a=input("输入”注册”创建账号:")
if a=="注册":
    user1=input("输入姓名:")
    sex=input("输入性别:")
    userku=input("输入账号:")
    psdku=input("输入密码:")
    print("注册成功,请登入账号")
user=input("输入账号:")
psd=input("输入密码:")
if user==userku and psd==psdku:
    print("欢迎尊敬的"+user1+"进入商店")
    print("个人信息:")
    hyjb=print("会员等级:普通")
    jf=0.00;
    print("姓名:"+user1)
    print("性别:"+sex)
else :
    print("账号密码错误!")
BuyGoods={}
good_index = input('请输入商品名称搜索(输入“Buy”退出):')
while good_index!='Buy':
    for key1 in product:
        if product[key1]["Name"].find(good_index)!=-1:
            tmpclass=product[key1]["Class"]
            print("请选择商品编号:")
            for key2 in product:
                if product[key2]["Class"].find(tmpclass)!=-1:
                    print("商品编号:{0:.3}   {1}    计价单位:{2}  单价:{3:.2f} 积分:{4:.2f}".format(key2,product[key2]["Name"],product[key2]["Unit"],product[key2]["Price"],product[key2]["integral"]))
            selected_good,Qty = input('请输入购买的3位编码、数量(空格隔开)|"end 0"退出:').split()
            while selected_good!='end':
                if len(selected_good)==3 and product[selected_good]!="":
                    BuyGoods[selected_good]={"Name":product[selected_good]["Name"],"Unit":product[selected_good]["Unit"],"Price":product[selected_good]["Price"],"integral":product[selected_good]["integral"],"Qty":eval(Qty)}
                selected_good,Qty = input('请输入购买的3位编码、数量(空格隔开)|"end 0"退出:').split()
            break
    good_index = input('请输入商品名称搜索(输入“Buy”退出):')
SubTotal=0.00;
print("*************结算**************")
print("你购买的商品、金额如下:")
for key3 in BuyGoods:
    print("商品编号:{0:.3}   {1}    计价单位:{2}  单价:{3:.2f} 积分:{4:.2f}".format(key3,BuyGoods[key3]["Name"],BuyGoods[key3]["Unit"],BuyGoods[key3]["Price"],BuyGoods[key3]["integral"],BuyGoods[key3]["Qty"]))
    SubTotal+=BuyGoods[key3]["Price"]*BuyGoods[key3]["Qty"]
    if hyjb=="普通":
        jf+=BuyGoods[key3]["integral"]*BuyGoods[key3]["Qty"]*1
    elif hyjb=="高级":
        jf+=BuyGoods[key3]["integral"]*BuyGoods[key3]["Qty"]*1.5
    elif hyjb=="银钻":
        jf+=BuyGoods[key3]["integral"]*BuyGoods[key3]["Qty"]*2
    elif hyjb=="金钻":
        jf+=BuyGoods[key3]["integral"]*BuyGoods[key3]["Qty"]*3
    elif hyjb=="黑钻":
        jf+=BuyGoods[key3]["integral"]*BuyGoods[key3]["Qty"]*6
    else:
        jf+=BuyGoods[key3]["integral"]*BuyGoods[key3]["Qty"]*0.5
    
    print("======合计金额:{:.2f}元".format(SubTotal),"获得积分:",int(jf))
    print("信息更新成功!!!")
    print("姓名:",user1)
    print("性别:",sex)
    print("会员等级:银钻","当前积分:",int(jf))
上一篇:gym102129F


下一篇:python – 使用scipy执行样本的离散集成