lundi 30 octobre 2017

Python 3.5 Fast Food Calculator

I am writing a simple program in Python. But I can't figure why it is not storing a value for Hcount, Scount, and Fcount. Also, it is not displaying the tax correctly. Any help would be appreciated

while True:

print("MacDoogle's:")
print("1. Hamburger = $1.50")
print("2. Soda      = $1.15")
print("3. Fries     = $1.25")
print("4. Complete Order")


choice = int(input('Make a selection: '))
while choice < 1 or choice > 4:
    choice = int(input('Enter a valid selection: '))

Hcount =0
Scount =0
Fcount =0 

if choice > 0 and choice <4:

    if choice == 1:
        amount1=int(input("Enter number of Hamburgers: "))
        Hcount += amount1

    elif choice == 2:
        amount2=int(input("Enter number of Sodas: "))
        Scount += amount2

    elif choice == 3:
        amount3=int(input("Enter number of Fries: "))
        Fcount += amount3

if choice == 4:
    sub=int((Hcount * 1.50) + (Scount * 1.15) + (Fcount * 1.25))
    tax=int(sub * 0.09)
    total=int(sub + tax)
    print('Number of Hamburgers:', format(Hcount, '3.0f'))
    print('Number of Sodas:', format(Scount, '3.0f'))
    print('Number of Fries:', format(Fcount, '3.0f'))
    print('Subtotal:', format(sub, '3.2f'))
    print('Tax:', format(tax, '3.2f'))
    print('Total:', format(total, '3.2f'))
    break

Aucun commentaire:

Enregistrer un commentaire