Java Reference
In-Depth Information
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 baseSalary denotes the base salary,
noOfServiceYears denotes the number of years that the salesperson has been with the
store, bonus denotes the bonus, totalSales denotes the total sales made by the sales-
person for the month, and additionalBonus 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 sales-
person's monthly paycheck:
1. Get baseSalary .
2. Get noOfServiceYears .
3. Calculate bonus using the following formula:
1
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 following equation:
payCheck = baseSalary + bonus + additionalBonus
 
Search WWH ::




Custom Search