Java Program Evaluation
annualCompensation_V2/build/classes/.netbeans_automatic_build
annualCompensation_V2/build/classes/.netbeans_update_resources
annualCompensation_V2/build/classes/calculateCompV2/CompCalculatorV2.class
package calculateCompV2; public synchronized class CompCalculatorV2 { private double annualSalary; private double commissionPercentage; public double annualCompenstation; private double salesTarget; private double commissionThreshold; private double salesCommissionThreshold; private double salesTargetBonusFactor; public void CompCalculatorV2(double); public double compResults(); }
annualCompensation_V2/build/classes/potentialCompensation/PotentialCompensation.class
package potentialCompensation; public synchronized class PotentialCompensation { public double nextSalesFigure; private double maxSales; private double salesIncrement; public void PotentialCompensation(double); }
annualCompensation_V2/build/classes/week3annualcompensation/Week3AnnualCompensation.class
package week3annualcompensation; public synchronized class Week3AnnualCompensation { public void Week3AnnualCompensation(); public static void main(String[]); }
annualCompensation_V2/build.xml
Builds, tests, and runs the project annualCompensation_V2.
annualCompensation_V2/Compensation/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
META-INF/MANIFEST.MF
Manifest-Version: 1.0 Ant-Version: Apache Ant 1.9.2 Created-By: 1.7.0_67-b01 (Oracle Corporation) NetBeans-Own-Library: true
org/netbeans/modules/java/j2seproject/copylibstask/Bundle.properties
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # # Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. # # Oracle and Java are registered trademarks of Oracle and/or its affiliates. # Other names may be trademarks of their respective owners. # # The contents of this file are subject to the terms of either the GNU # General Public License Version 2 only ("GPL") or the Common # Development and Distribution License("CDDL") (collectively, the # "License"). You may not use this file except in compliance with the # License. You can obtain a copy of the License at # http://www.netbeans.org/cddl-gplv2.html # or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the # specific language governing permissions and limitations under the # License. When distributing the software, include this License Header # Notice in each file and include the License file at # nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the GPL Version 2 section of the License file that # accompanied this code. If applicable, add the following below the # License Header, with the fields enclosed by brackets [] replaced by # your own identifying information: # "Portions Copyrighted [year] [name of copyright owner]" # # Contributor(s): # # The Original Software is NetBeans. The Initial Developer of the Original # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. # # If you wish your version of this file to be governed by only the CDDL # or only the GPL Version 2, indicate your decision by adding # "[Contributor] elects to include this software in this distribution # under the [CDDL or GPL Version 2] license." If you do not indicate a # single choice of license, a recipient has the option to distribute # your version of this file under either the CDDL, the GPL Version 2 or # to extend the choice of license to its licensees as provided above. # However, if you add GPL Version 2 code and therefore, elected the GPL # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. TXT_README_FILE_NAME=README.TXT TXT_README_FILE_CONTENT=========================\n\ BUILD OUTPUT DESCRIPTION\n\ ========================\n\ \n\ When you build an Java application project that has a main class, the IDE\n\ automatically copies all of the JAR\n\ files on the project's classpath to your project's dist/lib folder. The IDE\n\ also adds each of the JAR files to the Class-Path element in the application\n\ JAR file's manifest file (MANIFEST.MF).\n\ \n\ To run the project from the command line, go to the dist folder and\n\ type the following:\n\ \n\ java -jar '"{0}'" \n\ \n\ To distribute this project, zip up the dist folder (including the lib folder)\n\ and distribute the ZIP file.\n\ \n\ Notes:\n\ \n\ * If two JAR files on the project classpath have the same name, only the first\n\ JAR file is copied to the lib folder.\n\ * Only JAR files are copied to the lib folder.\n\ If the classpath contains other types of files or folders, these files (folders)\n\ are not copied.\n\ * If a library on the project's classpath also has a Class-Path element\n\ specified in the manifest,the content of the Class-Path element has to be on\n\ the project's runtime path.\n\ * To set a main class in a standard Java project, right-click the project node\n\ in the Projects window and choose Properties. Then click Run and enter the\n\ class name in the Main Class field. Alternatively, you can manually type the\n\ class name in the manifest Main-Class element.
org/netbeans/modules/java/j2seproject/copylibstask/CopyFiles.class
package org.netbeans.modules.java.j2seproject.copylibstask; public synchronized class CopyFiles extends org.apache.tools.ant.Task { private java.io.File todir; private java.io.File iftldtodir; private String files; private String manifestproperty; public void CopyFiles(); public void execute() throws org.apache.tools.ant.BuildException; private boolean containsTLD(java.io.File); public String getFiles(); public void setFiles(String); public java.io.File getToDir(); public void setToDir(java.io.File); public java.io.File getIfTLDToDir(); public void setIfTLDToDir(java.io.File); public String getManifestProperty(); public void setManifestProperty(String); static void <clinit>(); }
org/netbeans/modules/java/j2seproject/copylibstask/CopyLibs.class
package org.netbeans.modules.java.j2seproject.copylibstask; public synchronized class CopyLibs extends org.apache.tools.ant.taskdefs.Jar { private static final String LIB = lib; private static final String ATTR_CLASS_PATH = Class-Path; private static final String MANIFEST = META-INF/MANIFEST.MF; private static final String INDEX = META-INF/INDEX.LIST; private static final String UTF_8 = UTF-8; private static final String UTF8 = UTF8; private static final String URL_SEPARATOR = /; private static final String CP_SEPARATOR = ; org.apache.tools.ant.types.Path runtimePath; org.apache.tools.ant.types.Path excludeFromCopy; private boolean rebase; public void CopyLibs(); public void setRuntimeClassPath(org.apache.tools.ant.types.Path); public org.apache.tools.ant.types.Path getRuntimeClassPath(); public void setExcludeFromCopy(org.apache.tools.ant.types.Path); public org.apache.tools.ant.types.Path getExcludeFromCopy(); public boolean isRebase(); public void setRebase(boolean); public void setEncoding(String); public void addConfiguredManifest(org.apache.tools.ant.taskdefs.Manifest) throws org.apache.tools.ant.taskdefs.ManifestException; public void execute() throws org.apache.tools.ant.BuildException; private boolean rebase(java.io.File, java.io.File); private static boolean isSigned(org.apache.tools.ant.taskdefs.Manifest); private static void copy(java.io.InputStream, java.io.OutputStream) throws java.io.IOException; private static boolean isUTF8(String); private static String basename(String, String); private static transient String stringJoin(CharSequence, CharSequence[]); static void <clinit>(); }
org/netbeans/modules/java/j2seproject/copylibstask/antlib.xml
annualCompensation_V2/Compensation/lib/nblibraries.properties
libs.CopyLibs.classpath=\ ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar libs.CopyLibs.displayName=CopyLibs Task libs.CopyLibs.prop-version=2.0
annualCompensation_V2/Compensation/manifest.mf
Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build
annualCompensation_V2/Compensation/src/compensation/Compensation.java
annualCompensation_V2/Compensation/src/compensation/Compensation.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
compensation
;
/**
*
*
@author
anaperiera
*/
public
class
Compensation
{
/**
*
@param
args the command line arguments
*/
public
static
void
main
(
String
[]
args
)
{
// TODO code application logic here
}
}
annualCompensation_V2/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
META-INF/MANIFEST.MF
Manifest-Version: 1.0 Ant-Version: Apache Ant 1.9.2 Created-By: 1.7.0_67-b01 (Oracle Corporation) NetBeans-Own-Library: true
org/netbeans/modules/java/j2seproject/copylibstask/Bundle.properties
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # # Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. # # Oracle and Java are registered trademarks of Oracle and/or its affiliates. # Other names may be trademarks of their respective owners. # # The contents of this file are subject to the terms of either the GNU # General Public License Version 2 only ("GPL") or the Common # Development and Distribution License("CDDL") (collectively, the # "License"). You may not use this file except in compliance with the # License. You can obtain a copy of the License at # http://www.netbeans.org/cddl-gplv2.html # or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the # specific language governing permissions and limitations under the # License. When distributing the software, include this License Header # Notice in each file and include the License file at # nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the GPL Version 2 section of the License file that # accompanied this code. If applicable, add the following below the # License Header, with the fields enclosed by brackets [] replaced by # your own identifying information: # "Portions Copyrighted [year] [name of copyright owner]" # # Contributor(s): # # The Original Software is NetBeans. The Initial Developer of the Original # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. # # If you wish your version of this file to be governed by only the CDDL # or only the GPL Version 2, indicate your decision by adding # "[Contributor] elects to include this software in this distribution # under the [CDDL or GPL Version 2] license." If you do not indicate a # single choice of license, a recipient has the option to distribute # your version of this file under either the CDDL, the GPL Version 2 or # to extend the choice of license to its licensees as provided above. # However, if you add GPL Version 2 code and therefore, elected the GPL # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. TXT_README_FILE_NAME=README.TXT TXT_README_FILE_CONTENT=========================\n\ BUILD OUTPUT DESCRIPTION\n\ ========================\n\ \n\ When you build an Java application project that has a main class, the IDE\n\ automatically copies all of the JAR\n\ files on the project's classpath to your project's dist/lib folder. The IDE\n\ also adds each of the JAR files to the Class-Path element in the application\n\ JAR file's manifest file (MANIFEST.MF).\n\ \n\ To run the project from the command line, go to the dist folder and\n\ type the following:\n\ \n\ java -jar '"{0}'" \n\ \n\ To distribute this project, zip up the dist folder (including the lib folder)\n\ and distribute the ZIP file.\n\ \n\ Notes:\n\ \n\ * If two JAR files on the project classpath have the same name, only the first\n\ JAR file is copied to the lib folder.\n\ * Only JAR files are copied to the lib folder.\n\ If the classpath contains other types of files or folders, these files (folders)\n\ are not copied.\n\ * If a library on the project's classpath also has a Class-Path element\n\ specified in the manifest,the content of the Class-Path element has to be on\n\ the project's runtime path.\n\ * To set a main class in a standard Java project, right-click the project node\n\ in the Projects window and choose Properties. Then click Run and enter the\n\ class name in the Main Class field. Alternatively, you can manually type the\n\ class name in the manifest Main-Class element.
org/netbeans/modules/java/j2seproject/copylibstask/CopyFiles.class
package org.netbeans.modules.java.j2seproject.copylibstask; public synchronized class CopyFiles extends org.apache.tools.ant.Task { private java.io.File todir; private java.io.File iftldtodir; private String files; private String manifestproperty; public void CopyFiles(); public void execute() throws org.apache.tools.ant.BuildException; private boolean containsTLD(java.io.File); public String getFiles(); public void setFiles(String); public java.io.File getToDir(); public void setToDir(java.io.File); public java.io.File getIfTLDToDir(); public void setIfTLDToDir(java.io.File); public String getManifestProperty(); public void setManifestProperty(String); static void <clinit>(); }
org/netbeans/modules/java/j2seproject/copylibstask/CopyLibs.class
package org.netbeans.modules.java.j2seproject.copylibstask; public synchronized class CopyLibs extends org.apache.tools.ant.taskdefs.Jar { private static final String LIB = lib; private static final String ATTR_CLASS_PATH = Class-Path; private static final String MANIFEST = META-INF/MANIFEST.MF; private static final String INDEX = META-INF/INDEX.LIST; private static final String UTF_8 = UTF-8; private static final String UTF8 = UTF8; private static final String URL_SEPARATOR = /; private static final String CP_SEPARATOR = ; org.apache.tools.ant.types.Path runtimePath; org.apache.tools.ant.types.Path excludeFromCopy; private boolean rebase; public void CopyLibs(); public void setRuntimeClassPath(org.apache.tools.ant.types.Path); public org.apache.tools.ant.types.Path getRuntimeClassPath(); public void setExcludeFromCopy(org.apache.tools.ant.types.Path); public org.apache.tools.ant.types.Path getExcludeFromCopy(); public boolean isRebase(); public void setRebase(boolean); public void setEncoding(String); public void addConfiguredManifest(org.apache.tools.ant.taskdefs.Manifest) throws org.apache.tools.ant.taskdefs.ManifestException; public void execute() throws org.apache.tools.ant.BuildException; private boolean rebase(java.io.File, java.io.File); private static boolean isSigned(org.apache.tools.ant.taskdefs.Manifest); private static void copy(java.io.InputStream, java.io.OutputStream) throws java.io.IOException; private static boolean isUTF8(String); private static String basename(String, String); private static transient String stringJoin(CharSequence, CharSequence[]); static void <clinit>(); }
org/netbeans/modules/java/j2seproject/copylibstask/antlib.xml
annualCompensation_V2/lib/nblibraries.properties
libs.CopyLibs.classpath=\ ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar libs.CopyLibs.displayName=CopyLibs Task libs.CopyLibs.prop-version=2.0
annualCompensation_V2/manifest.mf
Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build
annualCompensation_V2/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.agent Must select some files in the IDE or set javac.includes To run this application from the command line without Ant, try: java -jar "${dist.jar.resolved}" Must select one file in the IDE or set run.class Must select one file in the IDE or set run.class Must select one file in the IDE or set debug.class Must select one file in the IDE or set debug.class Must set fix.includes This target only works when run from inside the NetBeans IDE. Must select one file in the IDE or set profile.class This target only works when run from inside the NetBeans IDE. This target only works when run from inside the NetBeans IDE. This target only works when run from inside the NetBeans IDE. Must select one file in the IDE or set run.class Must select some files in the IDE or set test.includes Must select one file in the IDE or set run.class Must select one file in the IDE or set applet.url Must select some files in the IDE or set javac.includes Some tests failed; see details above. Must select some files in the IDE or set test.includes Some tests failed; see details above. Must select some files in the IDE or set test.class Must select some method in the IDE or set test.method Some tests failed; see details above. Must select one file in the IDE or set test.class Must select one file in the IDE or set test.class Must select some method in the IDE or set test.method Must select one file in the IDE or set applet.url Must select one file in the IDE or set applet.url
annualCompensation_V2/nbproject/genfiles.properties
build.xml.data.CRC32=fa02f0ef build.xml.script.CRC32=60201f04 [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=fa02f0ef nbproject/build-impl.xml.script.CRC32=c41f80e7 nbproject/[email protected]
annualCompensation_V2/nbproject/private/private.properties
compile.on.save=true user.properties.file=/Users/anaperiera/Library/Application Support/NetBeans/8.1/build.properties
annualCompensation_V2/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}/annualCompensation_V2.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.external.vm=true 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=week3annualcompensation.Week3AnnualCompensation 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
annualCompensation_V2/nbproject/project.xml
org.netbeans.modules.java.j2seproject annualCompensation_V2 ./lib/nblibraries.properties
annualCompensation_V2/src/calculateCompV2/CompCalculatorV2.java
annualCompensation_V2/src/calculateCompV2/CompCalculatorV2.java
/**
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
calculateCompV2
;
/**
*This Class is the Compensation Calculator (CompCalculatorV2).
* This class is called to calculate the total annual compensation
* for a salesperson based on the person's annual salary and commission based on
* meeting the salesperson's sales target. The commission compensation begins
* only after the annuals sales reach 80% of the sales target. In addition, if
* the sales target is exceeded, then an addition bonus acceleration factor is
* applied to the commission.
* The CompCalculatorV2 is called by classes that require this calculation.This
* class returns to the calling class the annual compensation
* (variable annualCompenstation).
*
*
@author
Jaime Franqui
* Last update 5 February 2016
*/
public
class
CompCalculatorV2
{
/**
* Several access modifiers for variables are set to Private to
* prevent other classes from changing changing the assigned data.
* Future modifications of this code will pull
* the data from a collection or array based on the sales person ID.
*/
private
double
annualSalary
=
45000
;
//This is the sale's person salary
private
double
commissionPercentage
=
15
;
//This value is in percent
public
double
annualCompenstation
;
//The returned result from this class
private
double
salesTarget
=
120000
;
//current sales target for salespeople
private
double
commissionThreshold
=
80
;
//% of target to start commission
private
double
salesCommissionThreshold
=
0
;
//initialized to zero
private
double
salesTargetBonusFactor
=
1.33
;
//factor for exceeding target
/**The following class is called and supplied with the annual sales parameter
* that is entered by the sales person. The code calculates annual
* compensation.
*/
public
CompCalculatorV2
(
double
annualSales
)
{
//Constructor to initialize annualSales
salesCommissionThreshold
=
salesTarget
*
(
commissionThreshold
/
100
);
if
(
annualSales
>
salesTarget
)
{
//Yes, annual sales exceeds sales target, apply the bonus
annualCompenstation
=
annualSalary
+
(((
commissionPercentage
*
salesTargetBonusFactor
)
/
100
)
*
annualSales
);
//commissionPercentage*salesTargetBonusFactor applies an acceleration
//factor bonus for exceeding the sales target
//The "/100" converts to percentage to a decimal
}
else
{
//No, annual sales do not exceeds sales target
//check if sales are below sales commission threshold
if
(
annualSales
<
salesCommissionThreshold
)
{
//Yes, annual sales are less than the commission threshold
annualCompenstation
=
annualSalary
;
//salesperson gets no commission for sales
}
else
{
//No, annual sales are not less than the commission threshold
annualCompenstation
=
annualSalary
+
((
commissionPercentage
/
100
)
*
annualSales
);
//salesperson gets commission for sales
//The (commissionPercentage/100) converts to
//percentage to a decimal
}
//end if else
}
//end if else
}
//end constructor CompCalculatorV2
public
double
compResults
()
{
//returns annualCompenstation to the calling method
return
annualCompenstation
;
}
//End method compResults
}
//End class CompCalculatorV2
annualCompensation_V2/src/potentialCompensation/PotentialCompensation.java
annualCompensation_V2/src/potentialCompensation/PotentialCompensation.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
potentialCompensation
;
import
calculateCompV2
.
CompCalculatorV2
;
//For the Constructor
/**
*This Class is the PotentialCompensation.
* This creates a table that displays the potential total annual compensation
* that the salesperson could have earned, in $5000 increments above the
* salesperson's annual sales, until it reaches 50% above the salesperson's
* annual sales.
* The PotentialCompensation class calls the CompCalculatorV2 class to
* compute the annual compensations based on the nextSalesFigure value, which
* starts at the salesperson's actual annual sales.
*
*
@author
Jaime Franqui
* Last update 5 February 2016
*/
public
class
PotentialCompensation
{
/**
* Several access modifiers for variables are set to Private to
* prevent other classes from changing changing the assigned data.
*/
public
double
nextSalesFigure
=
0
;
//initialize at zero
private
double
maxSales
=
0
;
//initialize at zero
private
double
salesIncrement
=
5000
;
//initialize at $5,000.00
public
PotentialCompensation
(
double
sales
)
{
maxSales
=
sales
*
1.5
;
//sets max range of table to 50% above annual sales
nextSalesFigure
=
sales
;
//set to "sales" parameter sent from calling class
/**
* This next section creates and displays the table
*/
System
.
out
.
printf
(
"%-18s %-18s\n"
,
"For Total Sales"
,
"Total Compensation"
);
// Formats the printed output
//The format specifiers to create two column headers
//the %-18s %-18s create two left justified, 18 spaces wide, string
//columns for the table headers
//The \n creates a space after the strings entries are made
/**
* The following while-loop calls the CompCalculatorV2 class and passes
* the nextSalesFigure value to obtain the total compensation based on
* the nextSalesFigure value. The code then prints out both the sales
* value and new compensation value. The nextSalesFigure value is then
* incremented by salesIncrement after the values are printed. The loop
* continues until the nextSalesFigure reaches 50% above the actual
* salesperson's annual sales, which is the maxSales value.
*/
while
(
nextSalesFigure
<=
maxSales
)
{
CompCalculatorV2
showPotential
=
new
CompCalculatorV2
(
nextSalesFigure
);
//creates showPotential object to store the computed compensation
System
.
out
.
printf
(
"$%,-18.2f $%,-18.2f\n"
,
nextSalesFigure
,
showPotential
.
annualCompenstation
);
//Formats the printed output
//The format specifiers to create two columns of numbers
//The formatting specifiers start after the $ with the begin format
//The %,-18.2f %,-18.2f adds a comma format to the number output
//creates two left justified, 18 spaces wide columns
//The .2 formats the output for two decimal places.
//The "f" the output to floating point number
//The "\n" adds a new line after the output
//The output consist of nextSalesFigure, which is the "The Total Sales"
//column and the showPotential.annualCompenstation, which is the
//"Total Compensation" column.
nextSalesFigure
=
nextSalesFigure
+
salesIncrement
;
//this increments the sales figure by the salesIncrement value
}
//End while
}
//end constructor PotentialCompensation
}
//end class PotentialCompensation
annualCompensation_V2/src/week3annualcompensation/Week3AnnualCompensation.java
annualCompensation_V2/src/week3annualcompensation/Week3AnnualCompensation.java
/**
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
week3annualcompensation
;
import
calculateCompV2
.
CompCalculatorV2
;
//For the Constructor
import
java
.
util
.
Scanner
;
//for the Scanner class
import
java
.
util
.
InputMismatchException
;
import
potentialCompensation
.
PotentialCompensation
;
/**
* The Week3AnnualCompensation class is used to calculate the total annual
compensation of a salesperson. Once the class executes, it prompts the sales-
person to enter his or her annual salary. The class then calls and sends the
entered salary to the CompCalculatorV2 class where it factors in the
salesperson's annual salary and commission based on the sales to compute the
total annual compensation.
*
@author
Jaime Franqui
Last update 5 February 2016
*/
public
class
Week3AnnualCompensation
{
/**
*
@param
args the command line arguments
* The following is the main method and the start of the program
*/
public
static
void
main
(
String
[]
args
)
{
//Start class main
// Print this copy is from Franqui for teacher
System
.
out
.
println
(
"Franqui Week 3, Teacher's Copy"
);
/**
* The next portion of the will prompt the salesperson to enter
* in the annual sales data. Then it calls the CompCalculator class
*/
Scanner
userEnteredValue
=
new
Scanner
(
System
.
in
);
//Scanner(System.in) creates a wait for input in the program
/**
* The following do-while loop is used for error checking
*/
boolean
continueLoop
=
true
;
//continue loop if true (i.e., input wrong)
do
{
try
//reads the entered value
{
System
.
out
.
print
(
"Please use the keyboard to enter your annual sales $"
);
double
annualSales
=
userEnteredValue
.
nextDouble
();
//annualSales = value salesperson entered
if
(
annualSales
>=
0
)
{
// Yes: annualSales >= 0, execute the following code
/**
* This passes the annualSales parameter to the
* CompCalculator method (constructor)
*/
CompCalculatorV2
myComp
=
new
CompCalculatorV2
(
annualSales
);
/**
* The following prints out the computed results
*/
System
.
out
.
println
();
//creates an extra line
System
.
out
.
printf
(
"Your total annual compensation = $%,.2f\n\n"
,
myComp
.
annualCompenstation
);
// Formats the printed output
// The formatting specifiers start after the $ with the begin format
// specifier symbol "%" The"," formats the output so that a comma
// separates ever thousand in the number. The ".2" formats for two
// decimal places The "f" the output to floating point number, need
// since the output is a double precision number The "\n" adds a new
// line after the output
/**
* The following constructor initializes the
* PotentialCompensation class to produce a table showing
* potential compensation for increased annual sales
*/
new
PotentialCompensation
(
annualSales
);
//pass annualSales
continueLoop
=
false
;
// set false to break the loop
}
// end if true
else
{
//No: annualSales >= 0, execute the following code
System
.
out
.
println
(
"\nYou entered a negative dollar value.\n"
+
"Please try again with a value that is greater than or equal to zero.\n"
);
}
// end if
}
// end try// end try
/**
* if after trying, above results in an input mismatch exception
* then it will be caught below and then the loop retries
*/
catch
(
InputMismatchException
inputMismatchException
)
//Catches an InputMismatchException, identified as inputMismatchException
{
/**
* The following prints out the exception, then the
* request the salesperson to try entering value again
*/
System
.
err
.
printf
(
"\nException: %s\n"
,
inputMismatchException
);
userEnteredValue
.
nextLine
();
System
.
out
.
println
(
"You must enter nummeric value, Please try again.\n"
);
}
//end catch
}
while
(
continueLoop
);
// will continue loop until input is acceptable
/**
* This passes the annualSales parameter to the
* CompCalculator method (constructor)
*/
}
//End method main
}
//End class Week3AnnualCompensation