Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

program does not work, what did I do wrong?

#Sample Run:

#Welcome to your commission calculator!

#( $x,xxxx >= $20000(10%), < $20000 & >= $10000(7%), < $10000(5%) )

#Please enter sales: 20000

#Your commission is $2,000.00

# Congrats!
def main():

    sales_amount = 0.0
    commission = 0.0
    total_commission = 0.0

    welcome_message()

    sales_amount = get_sales_amount()

    commission = get_commission_calc(sales_amount)
    total_commission = sales_amount * commission_percent / 100, 2

    print_totals(total_commission)

def welcome_message():

    print("Welcome to your commission calculator!")

def get_sales_amount():

    sales = 0.0
    sales = float(input("Please enter sales: "))

    return sales

def get_commission_calc(sales_amount):

    commission_percent = 0.0

    if sales >= 20000:
        commission_percent = 10
    elif sales >= 10000:
        commission_percent = 7
    else:
        commission_percent = 5

    return sales

def print_totals(total_commission):

    print("Your commission is", '${:,.2f}'.format(total_commission))

    print("\n Congrats!")

>Solution :

There were several errors:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

sales_amount = 20000
def main():

    sales_amount = 0.0
    commission = 0.0
    total_commission = 0.0

    welcome_message()

    sales_amount = get_sales_amount()
    commission_percent = get_commission_calc(sales_amount) 
    total_commission = sales_amount * commission_percent / 100 #probably a typo of ", 2" and the variable name was wrong 
    
    print_totals(total_commission)
    
def welcome_message():

    print("Welcome to your commission calculator!")

def get_sales_amount():

    sales = 0.0
    sales = float(input("Please enter sales: "))

    return sales

def get_commission_calc(sales_amount):

    commission_percent = 0.0

    if sales_amount >= 20000: #variable name was wrong
        commission_percent = 10
    elif sales_amount >= 10000:
        commission_percent = 7
    else:
        commission_percent = 5

    return commission_percent #You are calculating commission percent from this function but it returned the sales

def print_totals(total_commission):

    print("Your commission is", '${:,.2f}'.format(total_commission))

    print("\n Congrats!")
    
main()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading