Individual: Write a simple commission calculation program using IDE.

profilejaego
src.zip

src/CommissionCalculation.java

src/CommissionCalculation.java

import  java . util . Scanner ;
import  java . text . NumberFormat ;

public   class   CommissionCalculation  
{
     public   static   void  main ( String  args [])
         {
             final   double  salesTarget = 600000 ;
            //create an object of Scanner class to get the keyboard input
             Scanner  keyInput  =   new   Scanner ( System . in );
            //for currency format
             NumberFormat  numberFormat  =   NumberFormat . getCurrencyInstance ();
            //creating an object of SalesPerson class
             SalesPerson  salesPerson  =   new   SalesPerson ();

             //prompt the user to enter the annual sales
             System . out . print ( "Enter the annual sales : " );
             double  sale  =   keyInput . nextDouble ();
             //Calculate normal commission until sales target is reached
             if ( sale <= salesTarget )
             {
                 //set the value of annual sale of sales person object
                salesPerson . setAnnualSales ( sale );
                 //displaying the report
                 System . out . println ( "The total annual compensation : " + numberFormat . format ( salesPerson . getAnnualCompensation ()));       
             }
             //show compensation table with Accelerated factor when sales target exceeds
             else
             {    
                 //method to show a compensation table if sales exceed 600000
                salesPerson . getCompensationTable ( sale );
             }
         }
}

src/SalesPerson.java

src/SalesPerson.java


public   class   SalesPerson   {
    
     private   final   double  fixedSalary   =   120000.00 ;
     private   final   double  commissionRate  =   1.2 ;
     private   final   double  salesTarget = 600000 ;
     private   final   double  accelerationfactor = 1.20 ;

     private   double  annualSales ;

     //default constructor
     public   SalesPerson ()   {
        annualSales  =   0.0 ;
     }

     //parameterized constructor
     public   SalesPerson ( double  aSale )   {
        annualSales  =  aSale ;
     }
    

     //getter method for the annual sales
     public   double  getAnnualSales (){
         return  annualSales ;
     }

     //method to set the value of annual sale
     public   void  setAnnualSales ( double  aSale )   {
        annualSales  =  aSale ;
     }

     //method to calculate and get commission
     public   double  getCommission ()
     {
         if ( annualSales <   ( 0.80 * salesTarget ))
         {
             return   0 ;
         }
         else  
         {  
             return  annualSales  *   ( commissionRate / 100.0 );
         }
     }
    
     //method to calculate and calculate Compensation with Accelerated commission and display table
     void  getCompensationTable ( double  annualSales )
     {
         int  count = 0 ;
         System . out . println ( "Annual Sales\t Total Compensation" );
         for ( annualSales = salesTarget ; annualSales <= (( salesTarget ) + ( 0.5 * salesTarget )); annualSales += 5000 )
         {
            count = count + 1 ;
             double  comm =  annualSales  *   ( commissionRate * Math . pow ( 1.2 , count ) / 100.0 );
             System . out . println ( annualSales + "\t" + ( fixedSalary + comm ));
         }    
     }
      
    
     //method to calculate and get annual compensation
     public   double  getAnnualCompensation (){
         return  fixedSalary   +  getCommission ();
     }

}