Write a program that includes two functions. The first function should ask a salesperson for the price value of daily sales and then return this figure to the main program. The second function should calculate the salesperson’s commission based on the following rates:Sales (in rs)commission0-9993%1000-29993.5%3000- up4.5%The calculated commission should be returned to the main program, which then displays it. Output:Enter the dollar value of daily sales: $1500Commission for the day: $52.50
Question
Write a program that includes two functions. The first function should ask a salesperson for the price value of daily sales and then return this figure to the main program. The second function should calculate the salesperson’s commission based on the following rates:Sales (in rs)commission0-9993%1000-29993.5%3000- up4.5%The calculated commission should be returned to the main program, which then displays it. Output:Enter the dollar value of daily sales: 52.50
Solution
Here is a Python program that fulfills your requirements:
def get_sales():
sales = float(input("Enter the dollar value of daily sales: $"))
return sales
def calculate_commission(sales):
if sales <= 999:
commission = sales * 0.03
elif sales <= 2999:
commission = sales * 0.035
else:
commission = sales * 0.045
return commission
def main():
sales = get_sales()
commission = calculate_commission(sales)
print("Commission for the day: $%.2f" % commission)
main()
This program works as follows:
-
The
main()function is called at the end of the program. This function first calls theget_sales()function, which asks the user to input the dollar value of daily sales and returns this value. -
The
main()function then calls thecalculate_commission(sales)function, passing the sales value as an argument. This function calculates the commission based on the sales value and the given commission rates, and returns the commission. -
Finally, the
main()function prints the commission for the day.
Similar Questions
IPS_6Write a program that includes two functions. The first function should ask a salesperson for the price value of daily sales and then return this figure to the main program. The second function should calculate the salesperson’s commission based on the following rates:Sales (in rs)commission0-9993%1000-29993.5%3000- up4.5%The calculated commission should be returned to the main program, which then displays it. Output:Enter the dollar value of daily sales: $1500Commission for the day: $52.50
A salesman gets a commission of 5% on the sales he makes if his sales is below Rs.5000/- and a commission of 8% on the sales that exceeds Rs.5000/- or equal to 5000 together with Rs.250/-.Write an algorithm or a flowchart and develop C program for computing the commission of the salesman, given his sales.
Linda is managing a small business and wants to calculate the total revenue based on the sales of two products. The price of the first product is 25 rupees, and the price of the second product is 40 rupees. Write a program that takes the quantity sold for each product as input and outputs the total revenue using arithmetic operators
Sales=40,000 variable cost=20% Fixed cost=30000 using Goal Seek analysis find the profit when sales is Rs.80000 Options : 34000 30000 22000 32000 do in excel
Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called computepay() and use the function to do the computation. The function should return a value. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use input to read a string and float() to convert the string to a number. Do not worry about error checking the user input unless you want to - you can assume the user types numbers properly. Do not name your variable sum or use the sum() function.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.