The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 402 Weeks Ago, 5 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
In this example, we design an algorithm that calculates the monthly paycheck of a salesperson at a local department store. Every salesperson has a base salary. The salesperson also receives a bonus at the end of each month, based on the following criteria: If the salesperson has been with the store for five years or less, the bonus is $10 for each year that he or she has worked there. If the salesperson has been with the store for more than five years, the bonus is $20 for each year that he or she has worked there. The salesperson can earn an additional bonus as follows: If the total sales made by the salesperson for the month are at least $5,000 but less than $10,000, he or she receives a
3% commission on the sale. If the total sales made by the salesperson for the month are at least
$10,000, he or she receives a 6% commission on the sale.
To calculate a salesperson’s monthly paycheck, you need to know the base salary, the number of years that the salesperson has been with the company, and the total sales made by the salesperson for that month. Suppose base Salary denotes the base salary, no Of Service Years denotes the number of years that the salesperson has been with the store, bonus denotes the bonus, total Sales denotes the total sales made by the salesperson for the month, and additional Bonus denotes the additional bonus. You can determine the bonus as follows:
if (noOfServiceYears is less than or equal to five)
bonus = 10 . noOfServiceYears
otherwise
bonus = 20 . noOfServiceYears
Next, you can determine the additional bonus of the salesperson as follows:
if (totalSales is less than 5000)
additionalBonus = 0
otherwise
if (totalSales is greater than or equal to 5000 and
totalSales is less than 10000)
additionalBonus = totalSales . (0.03)
otherwise
additionalBonus = totalSales . (0.06)
Following the above discussion, you can now design the algorithm to calculate a salesperson’s monthly paycheck:
1. Get baseSalary.
2. Get noOfServiceYears.
3. Calculate bonus using the following formula:
if (noOfServiceYears is less than or equal to five)
bonus = 10 . noOfServiceYears
otherwise
bonus = 20 . noOfServiceYears
4. Get totalSales.
5. Calculate additionalBonus using the following formula:
if (totalSales is less than 5000)
additionalBonus = 0
otherwise
if (totalSales is greater than or equal to 5000 and
totalSales is less than 10000)
additionalBonus = totalSales . (0.03)
otherwise
additionalBonus = totalSales . (0.06)
6. Calculate payCheck using the equation:
payCheck = baseSalary + bonus + additionalBonus
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll