如何为total = getCost修复此模块错误

时间:2020-02-22 00:23:36

标签: python python-3.8

我正在尝试计算total = getCost,但它一直在说其不受支持的操作数类型。我的上一个看起来与此设置相似,并且工作正常。不知道为什么这不起作用。 这是代码。

 def main():
        mealPrice = getPrice()
        tip = getTip(mealPrice)
        tax = getTax(mealPrice)
        total = getCost(mealPrice, tip, tax)
        printgetInfo(mealPrice, tip, tax, total)

    def getPrice():
        mealPrice = input('Enter the meal price $ ')
        mealPrice = float(mealPrice)
        return mealPrice


    def getTip(mealPrice):
        if (mealPrice >= .01)and(mealPrice <= 5.99):
            tip = mealPrice *.10
        elif (mealPrice >= 6)and(mealPrice <= 12):
            tip = mealPrice *.13
        elif (mealPrice >= 12.01)and(mealPrice <= 17):
            tip = mealPrice *.16
        elif (mealPrice >= 17.01)and(mealPrice <= 25):
            tip = mealPrice *.19
        else:
            tip = mealPrice *.22
            return tip


    def getTax(mealPrice):
        tax = mealPrice * .06
        return tax


    def getCost(mealPrice, tip, tax):
        total = mealPrice + tip + tax
        return total

    def getInfo(mealPrice, tip, tax, total):
        print('The meal price is $', mealPrice)
        print('The tip is $', tip)
        print('The tax is $', tax)
        #print('The total amount is $' total)


    main()

0 个答案:

没有答案