Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This is the compensation model for a sale's person's annual income. The
- * compensation model works as follows: - Each sales person has a base salary of
- * $53,000 - To receive a 5% bonus commission, they must meet 80% of their sales
- * target of $135,000 - If the meet or exceed 100% of their sales target, an
- * additional 1.1 multipler is applied
- *
- * @author Tony Simons
- */
- public class CompensationModel {
- // Base salary of the sales person
- private final double BASE_SALARY = 53000;
- // The comission bonus percentage
- private final double BONUS_PERCENTAGE = 5.0;
- // The annual sales target. If sales person meets COMMSSION_THRESHOLD_PERCENTAGE of this target
- // they will have a bonus.
- private final double SALES_TARGET = 135000;
- // Sales person must meet this percentage of their sales target to get a bonus
- private final double COMMISSION_THRESHOLD_PERCENTAGE = 80.0;
- // If the sales person meets 100% of the sales target, then this factor is applied to their bonus.
- private final double ACCELERATION_FACTOR = 1.1;
- // How much the person sold this year.
- private double salesAmount;
- /**
- * @return base salary of employee
- */
- public double getSalary() {
- return BASE_SALARY;
- }
- /**
- * @return the bonus percentage
- */
- public double getBonusPercentage() {
- return BONUS_PERCENTAGE;
- }
- /**
- * @param salesAmount The amount of sales the person achieved
- */
- public void setSalesAmount(double salesAmount) {
- this.salesAmount = salesAmount;
- }
- /**
- * @return the commission of the employee based on his actual sales amount
- */
- public double getSalesCommission() {
- return getSalesCommission(salesAmount);
- }
- /**
- * @return the theoretical commission he would've earned had he made annualSales amount this year.
- */
- public double getSalesCommission(double annualSales) {
- double commission = 0;
- if (annualSales >= COMMISSION_THRESHOLD_PERCENTAGE / 100.0 * SALES_TARGET) {
- commission = annualSales * BONUS_PERCENTAGE / 100.0;
- if (annualSales >= SALES_TARGET) {
- commission *= ACCELERATION_FACTOR;
- }
- }
- return commission;
- }
- /**
- * @return the employee's total compensation
- */
- public double getTotalCompensation() {
- return getSalesCommission() + BASE_SALARY;
- }
- }
Add Comment
Please, Sign In to add comment