Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

9. Use the Design Recipe to write a function called computeCommission that retur

ID: 3724601 • Letter: 9

Question

9. Use the Design Recipe to write a function called computeCommission that returns the commission earned by a salesperson for the sale of a car. The function should accept two parameters, first a string representing the model of the car sold and the second an int representing the number of upgrades that were sold. The commission follows these rules:

The commission earned on a basic model (“basic”) is $1000, on a mid-range model (“mid”) is $1500 and on a luxury model (“luxury”) is $2000. You may assume that these are the only three string values that will be passed to your function.

The salesperson earns $100 per upgrade to the models. You may assume that upgrades are always greater than or equal to zero.

PYTHON LANGUAGE

Explanation / Answer

#program written in pyton

#calculating the commsion

def main():

    #displays car name and report

    print("carname1")

    print("car sales report")

    print()

    get_data1()

    get_salepersons()

    get_salesrep()

#opens the file for read and calculations

def get_data1():

  cars_numbers = open('CarsData.txt','r')

    num_list1 = cars_numbers.readlines()

    cars_numbers.close()

    ind = 0

    while ind < len(num_list1):

        num_list1[ind] = num_list1[ind].rstrip(' ')

        ind += 1

    return num_list1         

#gets info from salepersons and calculates commission

def get_salepersons():

    line1 = get_data1()

    ind= 0

    total1 = 0

    average 1= 0

    commission1 = 0

upgrade=100

    while ind < len(line1):

        name1 = line1[ind]

        if ind% 12== 0 and ind != 0:

            #if statement is used to determine commission

            print ("Total car sales: $"+str(round(total1,2)))

                #basic range car commission compute

            if tota1l < 50000 :

#commision in dollars

                commission = 1000;

#mid range

            elif total < 100000 :

                commission = 1500;

#luxury car commission compute

            elif total < 7000000 :

                commission = 2000;

           

            print ("Total Commission for the cars sales is : $"+str(round(commission,2)))

            if total1 >0 :

                #extra money for upgrading models

                upgrade=total1*upgrade

                print ("Extra money earned by salesperson"+str(round(upgrade,2)))

          else :

                          print ("no money added for 0 upgradation”)

                            total 1= 0

        if " " in line1[ind] :

            split1 = name.split(', ')

            print (split1[1]+' '+split1[0])

        if "." in line1[ind] :

            total 1+= float(line1[ind])

        ind += 1

    print("Total car sales: $"+str(round(total1,2)))

    print("Total Commission got is: $"+str(round(commission,2)))

main()

Output

If the salesperson sell the car at 40000 he get 1000 as commsion

If he sell at below 100000 he get 15000 commison

If he sell at above 10000000 he get 2000 commison

These are my assumptions