Application Part III

profilevaaredf
commissionwk3.zip

commission wk3/Commission.java

commission wk3/Commission.java


package   Job ;

/**
 *
 * Jarred
 */
import  java . util . Scanner ;

/**
 * * *  @author  Bonie
 */
public   class   Commission   {

     /**
     * *  @param  args the command line arguments
     *  @param  args
     */
     public   static   void  main ( String []  args )   {
         Scanner  sc  =   new   Scanner ( System . in );

         System . out . println ( "Enter the Total Annual Sales of the Person" );
// Request for User Input for Annual Sales 
         int  annualsales  =  sc . nextInt ();
// Read the input as Integer and assign it to annualsales variable 
         System . out . println ( "With an Annual Salary of $100,000 and 15 % commision on total annual sales" );
//display his salary and commision rate 
         SalesPerson  sp ; // Create an Instance of a new sales person 
        sp  =   /*new*/   SalesPerson ( annualsales );
        sp . computeTotalAnnualCompensation ( annualsales );
         System . out . println ( "The Annual Compensation is "   +  sp . getTotalAnnualCompensation ());
//Calculate the annual compensation and output 

         int  n ;   //the number of 10000 values possible from 50% sales amount
        n  =   ( int )   (( 0.5   *  sp . getAnnualSales ())   /   10000 );
         for   ( int  i  =   0 ;  i  <  n ;  i ++ )   {
            sp . computeTotalAnnualCompensation ( sp . getAnnualSales ()   +   10000 );
             System . out . println ( "<<Program calculated value>> \n"   +  sp . getTotalAnnualCompensation ());
         }
     }
}

commission wk3/SalesPerson.java

commission wk3/SalesPerson.java




/**
 *
 * Jarred
 */
class   SalesPerson   {

     //variable declaration 
     private   float  totalAnnualCompensation ;
     public   final   int  FIXED_SALARY  =   100000 ;
     public   final   int  SALES_TARGET  =   200000 ;
     private   float  commission ;
     private   float  salary  =  FIXED_SALARY ;
     private   float  annualSales ;

     /**
     * the SalesPerson constructor which takes only annual sales amount an 
     * integer 
     *  @param  annualSales 
     */
     SalesPerson ( int  annualSales )   {
         this . annualSales  =  annualSales ;

     }

/**
 * GetAnnualSales returns the annual sales amount
 *  @return  annual sales 
 */
     public   float  getAnnualSales ()   {
         return  annualSales ;
     }

     /**
     * The computeTotalAnnualCompensation method as the name suggest determines
     * the total annual compensation depending on the annual sales amount compared 
     * to target sales
     *  @param  annualSales 
     */
     public   void  computeTotalAnnualCompensation ( float  annualSales )   {
         this . annualSales  =  annualSales ;
         double  the80pctOfSales  =   0.8   *  annualSales ;

         if   ( the80pctOfSales  >=  SALES_TARGET )   {
             if   ( annualSales  >=   ( SALES_TARGET  /   1.2 ))   {
                salary  =   ( float )   ( FIXED_SALARY  *   1.15 );
                commission  =   ( float )   ( 0.15   *   this . annualSales );
             }   else   {
                commission  =   ( float )   ( 0.15   *   this . annualSales );
             }
         }
         this . totalAnnualCompensation  =  salary  +  commission ;

     }

     /**
     * this method return the amount of total annual compensation 
     *  @return  totalAnnualCompensation
     */
     float  getTotalAnnualCompensation ()   {

         return   this . totalAnnualCompensation ;
     }

}