num=[5,6,5,4,2,6,4]
cakeinfo = (("1","冰雪奇缘",120),("2","悉尼之风",100),("3","泡泡玛丽",110),('4','甜蜜城堡',110),('5','粉红小猪',90),('6','哆啦圆梦',100),('7','甜蜜梦乡',120))
print("编号","蛋糕名称","蛋糕价格",'库存')
for index in range (len(cakeinfo)):
print("{:^3}{:>6}{:>8}{:>6}".format(cakeinfo[index][0],cakeinfo[index][1],cakeinfo[index][2],num[index]))
money = 0
card = [ ]
while True :
num = int(input("请输入商品编号:"))
money += cakeinfo[num-1][2]
print("已成功加入购物车!")
card.append(cakeinfo[num-1][1])
print("当前购物车里有",card)
print("一共消费:",money)
flag = input("还要继续购物吗?按n键退出,按回车键继续……")
if flag=='n':
break
print("编号","蛋糕名称","蛋糕价格",'库存')
num2=[4,6,5,4,2,6,3]
for index in range (len(cakeinfo)):
print("{:^3}{:>6}{:>8}{:>6}".format(cakeinfo[index][0],cakeinfo[index][1],cakeinfo[index][2],num2[index]))
sum=int(input("请输入金额:"))
if sum<money :
print("金额不足,还差:",money-sum)
else:
print("找零:",sum-money)
print("欢迎下次光临!")
cakeinfo = (("1","冰雪奇缘",120),("2","悉尼之风",100),("3","泡泡玛丽",110),('4','甜蜜城堡',110),('5','粉红小猪',90),('6','哆啦圆梦',100),('7','甜蜜梦乡',120))
print("编号","蛋糕名称","蛋糕价格",'库存')
for index in range (len(cakeinfo)):
print("{:^3}{:>6}{:>8}{:>6}".format(cakeinfo[index][0],cakeinfo[index][1],cakeinfo[index][2],num[index]))
money = 0
card = [ ]
while True :
num = int(input("请输入商品编号:"))
money += cakeinfo[num-1][2]
print("已成功加入购物车!")
card.append(cakeinfo[num-1][1])
print("当前购物车里有",card)
print("一共消费:",money)
flag = input("还要继续购物吗?按n键退出,按回车键继续……")
if flag=='n':
break
print("编号","蛋糕名称","蛋糕价格",'库存')
num2=[4,6,5,4,2,6,3]
for index in range (len(cakeinfo)):
print("{:^3}{:>6}{:>8}{:>6}".format(cakeinfo[index][0],cakeinfo[index][1],cakeinfo[index][2],num2[index]))
sum=int(input("请输入金额:"))
if sum<money :
print("金额不足,还差:",money-sum)
else:
print("找零:",sum-money)
print("欢迎下次光临!")