Salesperson JAVA Application Part III

profileNew_Network
Week3.zip

main.java

main.java

import  java . util . Scanner ;


public   class   DriverCalculator   {
     public   static   void  main ( String  args []){
         double  annualSales ;
         SalesPerson  person ;
         Scanner  input = new   Scanner ( System . in );
         System . out . print ( "Please enter your total sales for the year: " );
        annualSales = input . nextDouble ();
        person = new   SalesPerson ( annualSales );
         System . out . println ( " Your total compensation for the year: $" + String . format ( "%.2f" ,  person . getTotalAnnualCompensation ()));

         System . out . println ( "Total Sales              Total Compensation" );
        annualSales =  annualSales ;
         for ( int  i = 0 ; i < 11 ; i ++ ){
            person = new   SalesPerson ( annualSales );
              System . out . println ( "$" +  annualSales + "                " + "$" + String . format ( "%.2f" ,  person . getTotalAnnualCompensation ()));
            annualSales += 5000 ;
         }
     }
}

salesperson.java

salesperson.java

public   class   SalesPerson   {
// create variable (fixedSalary)
  double  fixedSalary ;
  // variable of the value of sale person's annual sales
  double   annualSales ;
  //commission that is earned
  double  commission ;
  //The target for sales that must be reached by sales person
  double  target ;
  public   SalesPerson ( double  annualSales ){
      this . annualSales = annualSales ;
     target = 140000 ;
     commission = 0 ;
      if ( annualSales > target * 0.8 ){
         if ( annualSales < target ) commission = 0.25 * annualSales ; //The current commission 25% of total sales.
         else  commission = 0.25 * 1.25 * annualSales ; //The current commission (0.25*1.25)% of total sales.
      }
     fixedSalary = 75000 ; // set fixed salary is 75000$
  }
  public   double  getTotalAnnualCompensation (){ // calculate The total annual compensation is the fixed salary plus the commission earned
      return  fixedSalary + commission ;
  }
}