Guest User

Untitled

a guest
Jan 18th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.26 KB | None | 0 0
  1. /**
  2.  * This is the compensation model for a sale's person's annual income. The
  3.  * compensation model works as follows: - Each sales person has a base salary of
  4.  * $53,000 - To receive a 5% bonus commission, they must meet 80% of their sales
  5.  * target of $135,000 - If the meet or exceed 100% of their sales target, an
  6.  * additional 1.1 multipler is applied
  7.  *
  8.  * @author Tony Simons
  9.  */
  10. public class CompensationModel {
  11.     // Base salary of the sales person
  12.     private final double BASE_SALARY = 53000;
  13.     // The comission bonus percentage
  14.     private final double BONUS_PERCENTAGE = 5.0;
  15.     // The annual sales target.  If sales person meets COMMSSION_THRESHOLD_PERCENTAGE of this target
  16.     // they will have a bonus.
  17.     private final double SALES_TARGET = 135000;
  18.     // Sales person must meet this percentage of their sales target to get a bonus
  19.     private final double COMMISSION_THRESHOLD_PERCENTAGE = 80.0;
  20.     // If the sales person meets 100% of the sales target, then this factor is applied to their bonus.
  21.     private final double ACCELERATION_FACTOR = 1.1;
  22.    
  23.     // How much the person sold this year.
  24.     private double salesAmount;
  25.    
  26.     /**
  27.      * @return base salary of employee
  28.      */
  29.     public double getSalary() {
  30.         return BASE_SALARY;
  31.     }
  32.    
  33.     /**
  34.      * @return the bonus percentage
  35.      */
  36.     public double getBonusPercentage() {
  37.         return BONUS_PERCENTAGE;
  38.     }
  39.  
  40.     /**
  41.      * @param salesAmount The amount of sales the person achieved
  42.      */
  43.     public void setSalesAmount(double salesAmount) {
  44.         this.salesAmount = salesAmount;
  45.     }
  46.    
  47.     /**
  48.      * @return the commission of the employee based on his actual sales amount
  49.      */
  50.     public double getSalesCommission() {
  51.         return getSalesCommission(salesAmount);
  52.     }
  53.    
  54.     /**
  55.      * @return the theoretical commission he would've earned had he made annualSales amount this year.
  56.      */
  57.     public double getSalesCommission(double annualSales) {
  58.         double commission = 0;
  59.         if (annualSales >= COMMISSION_THRESHOLD_PERCENTAGE / 100.0 * SALES_TARGET) {
  60.             commission = annualSales * BONUS_PERCENTAGE / 100.0;
  61.             if (annualSales >= SALES_TARGET) {
  62.                 commission *= ACCELERATION_FACTOR;
  63.             }
  64.         }
  65.         return commission;
  66.     }
  67.  
  68.     /**
  69.      * @return the employee's total compensation
  70.      */
  71.     public double getTotalCompensation() {
  72.         return getSalesCommission() + BASE_SALARY;
  73.     }
  74. }
Add Comment
Please, Sign In to add comment