Add an Array to an existing Java Program
Simple Commsion Calculation/build.xml
Builds, tests, and runs the project Simple Commsion Calculation.Simple Commsion Calculation/manifest.mf
Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build
Simple Commsion Calculation/nbproject/build-impl.xml
Must set src.dir Must set test.src.dir Must set build.dir Must set dist.dir Must set build.classes.dir Must set dist.javadoc.dir Must set build.test.classes.dir Must set build.test.results.dir Must set build.classes.excludes Must set dist.jar Must set javac.includes No tests executed. Must set JVM to use for profiling in profiler.info.jvm Must set profiler agent JVM arguments in profiler.info.jvmargs.agentSimple Commsion Calculation/nbproject/genfiles.properties
build.xml.data.CRC32=fc93565a build.xml.script.CRC32=bc3fd3f6 [email protected] # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=fc93565a nbproject/build-impl.xml.script.CRC32=fa3fac4c nbproject/[email protected]
Simple Commsion Calculation/nbproject/project.properties
annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processor.options= annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: build.dir=build build.generated.dir=${build.dir}/generated build.generated.sources.dir=${build.dir}/generated-sources # Only compile against the classpath explicitly listed here: build.sysclasspath=ignore build.test.classes.dir=${build.dir}/test/classes build.test.results.dir=${build.dir}/test/results # Uncomment to specify the preferred debugger connection transport: #debug.transport=dt_socket debug.classpath=\ ${run.classpath} debug.test.classpath=\ ${run.test.classpath} # Files in build.classes.dir which should be excluded from distribution jar dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist dist.jar=${dist.dir}/Simple_Commsion_Calculation.jar dist.javadoc.dir=${dist.dir}/javadoc excludes= includes=** jar.compress=false javac.classpath= # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false javac.processorpath=\ ${javac.classpath} javac.source=1.8 javac.target=1.8 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir} javac.test.processorpath=\ ${javac.test.classpath} javadoc.additionalparam= javadoc.author=false javadoc.encoding=${source.encoding} javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=false javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= main.class=simple.commsion.calculation.SimpleCommsionCalculation manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false platform.active=default_platform run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} # Space-separated list of JVM arguments used when running the project. # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. # To set system properties for unit tests define test-sys-prop.name=value: run.jvmargs= run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} source.encoding=UTF-8 src.dir=src test.src.dir=test
Simple Commsion Calculation/nbproject/project.xml
org.netbeans.modules.java.j2seproject Simple Commsion CalculationSimple Commsion Calculation/src/simple/commsion/calculation/SalesPerson.java
Simple Commsion Calculation/src/simple/commsion/calculation/SalesPerson.java
/*
* Title: Simple Commision Calculation
* Programmer: Melody Frost
* PRG 420 Java Programming I
* Instructor: Henry Williams
* University of Phoenix
* This program will calculate the total annual compesation of a sales person.
* Sales commision of 15% and prompt user to end annual sales plus displays
* total annual compensation
*/
package
simple
.
commsion
.
calculation
;
/**
*
*
@author
Melody Frost
*/
class
SalesPerson
{
/**
* Instance variables for storing data
*/
private
double
fixedCompensation
;
private
double
variablePercent
;
/**
* Default constructor
*/
public
SalesPerson
()
{
}
/**
*
*
@param
fixedCompensation
*
@param
variablePercent
*/
public
SalesPerson
(
double
fixedCompensation
,
double
variablePercent
)
{
this
.
fixedCompensation
=
fixedCompensation
;
this
.
variablePercent
=
variablePercent
;
}
/**
* accessors method for fixedCompensation
*
*
@return
fixedCompensation
*/
public
double
getFixedCompensation
()
{
return
fixedCompensation
;
}
/**
* Mutator for fixedCompensation
*
*
@param
fixedCompensation
*/
public
void
setFixedCompensation
(
double
fixedCompensation
)
{
this
.
fixedCompensation
=
fixedCompensation
;
}
/**
* accessors for variablePercent
*
*
@return
variablePercent
*/
public
double
getVariablePercent
()
{
return
variablePercent
;
}
/**
* Mutator for variablePercent
*
*
@param
variablePercent
*/
public
void
setVariablePercent
(
double
variablePercent
)
{
this
.
variablePercent
=
variablePercent
;
}
/**
* This method calculates and returns the total compensation.
*
*
@param
sales
*
@return
totalCompensation
*/
public
double
calculateTotalCompensation
(
double
sales
)
{
// Assume sales target is 150,000
double
salesTarget
=
150000
;
// Sales incentive will kick in only if 80% of sales target has been reached
// and up to sales target
double
salesNeededForIncentive
=
0.80
*
salesTarget
;
double
commissionRate
;
// All sales that exceed the sales target will earch an acceleration of 2.0.
double
accelerationFactor
=
2.0
;
if
(
sales
>
salesNeededForIncentive
&&
sales
<=
salesTarget
)
{
commissionRate
=
getVariablePercent
();
}
else
if
(
sales
>
salesTarget
)
{
// Above the target, the commission increases to incentiveRate x
// acceleration factor
commissionRate
=
accelerationFactor
;
}
else
{
// Target not met
commissionRate
=
0
;
}
return
getFixedCompensation
()
+
(
sales
*
commissionRate
);
}
}
Simple Commsion Calculation/src/simple/commsion/calculation/SimpleCommsionCalculation.java
Simple Commsion Calculation/src/simple/commsion/calculation/SimpleCommsionCalculation.java
/*
* Title: Simple Commision Calculation Week 3
* Programmer: Melody Frost
* PRG 420 Java Programming I
* Instructor: Henry Williams
* University of Phoenix
* This program will calculate the total annual compesation of a salesperson.
* * Sales commision of 15% and prompt user ot end annual sales plus displays
* total annual compensation
*/
package
simple
.
commsion
.
calculation
;
import
java
.
text
.
NumberFormat
;
import
java
.
util
.
Locale
;
import
java
.
util
.
Scanner
;
/**
*
*
@author
Melody Frost
*/
public
class
SimpleCommsionCalculation
{
/**
* Program execution starts here
*
*
@param
args the command line arguments
*/
public
static
void
main
(
String
[]
args
)
{
// Command to format currency
NumberFormat
numberFormat
=
NumberFormat
.
getCurrencyInstance
(
Locale
.
US
);
// Command for accepting input
Scanner
input
=
new
Scanner
(
System
.
in
);
// Command to prompt the user and accept sales amount
System
.
out
.
print
(
"Enter sales: "
);
double
sales
=
input
.
nextDouble
();
// Fixed annual salary of 85000 and commission rate of 15%
double
fixedSalary
=
850000
;
double
commissionRate
=
0.15
;
// Command to initialize sales person object with default values
SalesPerson
salesPerson
=
new
SalesPerson
(
fixedSalary
,
commissionRate
);
// Command to calculate the total compensation and display it in
// currency format
System
.
out
.
println
(
"Total compensation: "
+
numberFormat
.
format
(
salesPerson
.
calculateTotalCompensation
(
sales
)));
// Create table for possible total compensation
double
maxSales
=
2.0
*
sales
;
double
salesAmount
=
sales
;
System
.
out
.
println
(
"Total Sales\t\tTotal compensation"
);
while
(
salesAmount
<=
maxSales
)
{
System
.
out
.
println
(
numberFormat
.
format
(
salesAmount
)
+
"\t\t"
+
numberFormat
.
format
(
salesPerson
.
calculateTotalCompensation
(
salesAmount
)));
salesAmount
=
salesAmount
+
5000
;
}
}
}