Modify the Week Three Java application using NetBeans IDE to meet these additional and changed business requirements:
- The application will now compare the total annual compensation of at least two salespersons.
- It will calculate the additional amount of sales that each salesperson must achieve to match or exceed the higher of the two earners.
- The application should ask for the name of each salesperson being compared.
The Java application should also meet these technical requirements:
- The application should have at least one class, in addition to the application’s controlling class.
- The source code must demonstrate the use of Array or ArrayList.
- There should be proper documentation in the source code.
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
(
"<
+
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
;
}
}