赞
踩
用anaconda实现
代码段一:#费用计算函数
def getCharge(drinkNo,foodNo):
drinkCharge = 0.0
foodCharge = 0.0
if drinkNo == 1:
drinkCharge = 3.0
elif drinkNo == 2:
drinkCharge = 4.5
elif drinkNo == 3:
drinkCharge = 4.0
if foodNo == 1:
foodCharge = 1.0
elif foodNo == 2:
foodCharge = 2.5
elif foodNo == 3:
foodCharge = 2.0
elif foodNo == 4:
foodCharge = 1.5
return drinkCharge + foodCharge
代码段二:#点餐模块
import time
DrinkMenu = {1:'豆浆',2:'果汁',3:'牛奶'}
FoodMenu = {1:'馒头',2:'包子',3:'鸡蛋',4:'油条'}
OrderList = []
def orderMenu():
print('\n----------欢迎点餐------------')
print('我们提供的饮品:')
for drink in DrinkMenu:
print(str(drink)+':'+DrinkMenu[drink])
drinkNo = int(input('请输入序号选择您需要的饮品(1~3):'))
print(drinkNo)
while drinkNo > 3:
drinkNo = int(input('输入错误,请输入序号选择您序号的饮品(1~3)'))
print('您选择了:'+DrinkMenu[drinkNo]+'\n')
print('我们提供的食物:')
for food in FoodMenu:
print(str(food)+':'+FoodMenu[food])
foodNo=int(input('请输入序号选择您需要的食物(1~4):'))
while foodNo > 4:
foodNo = int(input('输入错误,请输入需要选择您需要的食物(1~4)'))
print('您选择了:'+FoodMenu[foodNo]+'\n')
totalPrice = getCharge(drinkNo,foodNo)
print('将马上为您奉上%s和%s,共消费%.2f元。'%(DrinkMenu[drinkNo],FoodMenu[foodNo],totalPrice))
OrderDate = time.strftime('%Y-%m-%d',time.localtime(time.time()))
OrderTime = time.strftime('%H:%M:%S',time.localtime(time.time()))
OrderList.append([OrderDate,OrderTime,DrinkMenu[drinkNo],FoodMenu[foodNo],totalPrice])
代码段三:#代码执行
while(True):
print('\n-----------欢迎使用点餐系统---------------')
print('本软件提供如下功能:\n1.点餐\n2.打印报表\n3.存储报表\n4.退出系统')
choice=int(input('请输入数字选择一项功能:'))
if choice == 1:
orderMenu()
elif choice == 2:
printReport(OrderList)
elif choice == 3:
exportReport(OrderList)
elif choice == 4:
exit(0)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。