Algorithm for a solution that prints the amount of profit an organisation receives based on its sales. The more sales documented, the larger the profit ratio. Allow the user to input the total sales figure for the organisation. Compute the profit based on the following table. Display the sales and profit formatted with commas, decimals, and a rand symbol. Display the profit ratio formatted with a percent symbol. 0 – R1000: 3.0% / R1000.01 – R5000: 3.5% / R5000.01 – R10000: 4.0% / over R10000: 4.5%
Algorithm:
1. Read sales
2. if sales sales less or equal 1000
3. set ratio to 3
4. go to step
5. if sales sales less or equal 5000
6. set ratio to 3.5
7. go to step
8. if sales sales less or equal 10000
9. set ratio to 4
10. go to step
11. set ratio to 4.5
12. mset profile equal sale*ratio/100
13. print results
Program on Python:
sales = float(input("Enter a sale value: "))
if sales <= 1000:
rate = 3.0
elif sales <= 5000:
rate = 3.5
elif sales <= 10000:
rate = 4.0
else:
rate = 4.5
profit = sales * rate/100
print(f'Sales: R{sales:.2f}, profit: R{profit:.2f} {rate:.1f}%')
Comments
Leave a comment