I need to calculate the total purchase price of the books. The discount is determined by the amount of books purchased. Those are split within the if statements. How can I have my code fully work is currently is giving me this error message: 
BOOK_PRICE = 100
def main():
numBooks = int(input("Enter the number of books you will be purchasing: "))
eligibleDiscount(numBooks)
totalPrice(numBooks)
def eligibleDiscount(numBooks):
if numBooks <= 0 and numBooks <= 9:
print(" ")
print("Your TOTAL PURCHASE PRICE is: $ ",totalPrice)
if numBooks >= 10 and numBooks <= 19:
print("Since you are ordering",numBooks,"books you will receive a 20% discount!")
print("Your TOTAL PURCHASE PRICE is: $ ",totalPrice)
if numBooks >= 20 and numBooks <= 49:
print("Since you are ordering",numBooks,"books you will receive a 30% discount!")
print("Your TOTAL PURCHASE PRICE is: $ ",totalPrice)
if numBooks >= 50 and numBooks <= 99:
print("Since you are ordering",numBooks,"books you will receive a 40% discount!")
print("Your TOTAL PURCHASE PRICE is: $",totalPrice)
if numBooks >= 100:
print("Since you are ordering",numBooks,"books you will receive a 50% discount!")
discountRate = .50
print("Your TOTAL PURCHASE PRICE is: $",totalPrice)
def totalPrice(theTotalPrice):
subTotal = (numBooks * BOOK_PRICE)
discountPrice = (numBooks * discountRate)
theTotalPrice = (subTotal - discountPrice)
return theTotalPrice
main()
Aucun commentaire:
Enregistrer un commentaire