Modify the Week Two Java non-GUI console application using NetBeans IDE (or jGrasp) to meet these additional and   changed business requirements:

• The company has recently changed its total annual compensation policy to improve sales.
• A salesperson will continue to earn a fixed salary of $35,000.00. The current sales target for every salesperson is $120,000.00.
• The sales incentive will only start when 80% of the sales target is met. The current commission is 15% of total sales.
• If a salesperson exceeds the sales target, the commission will increase based on an acceleration factor. The acceleration factor is 1.25%.
• The application should ask the user to enter annual sales, and it should display the total annual compensation.
• The application should also display a table of 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.
Sample Table: Assuming a total annual sales of $100,000, the table would look like this:

  Total Sales   Total Compensation
100,000 <<Program calculated value>>
105,000 <<Program calculated value>>
110,000 <<Program calculated value>>
115,000 <<Program calculated value>>
120,000 <<Program calculated value>>
125,000 <<Program calculated value>>
130,000 <<Program calculated value>>
135,000 <<Program calculated value>>
140,000 <<Program calculated value>>
145,000 <<Program calculated value>>
150,000 <<Program calculated value>>
Note: The table should start with the Annual Sales entered by the user.

And so when I compile my work, I get this 
 *This class calculate the annual compensation of the sales person.
 package commission;

  *@author Monique
      public class Salesperson {

  //Private Variable of the salesperson class;
      private double fixedSalary = 35000;
      private double salesTarget = 120000;
      private float mininumSales = 0.80f;
      private double commissionRate = 0.015;
      private float accelerateFactor = 0.0125f;

      public double compensation(double annualSalary){
     //Calculate the total annual compensation.

     double minSalesCalc=saleTarget*mininumSales;    //Calculate mininum sales required for Commission.

     int differ = Double.compare(annualSales, minSalesCalc);
     //if the differ variable is negative, the annualSales is considered smaller than the minSalesCalc
     //if the differ variable is positive, the annualSales is considered larger than the minSalesCalc
     //if the differ variable is 0, the values are considered to be equal.
     if (differ>=0) {    //check Sale person exceeds 80% of sales target or not.
     if (annualSales>salesTarget);{    //check Sales person exceeds of sales target or not.
         minSalesCalc+=(annualSales-salesTarget)*accelerationFactor;    //add acceleration factor.
         minSalesCalc+=annualSales*commissionRate; {
     return minSalesCalc; 

And the Compile answer to what I just did, is this

----jGRASP exec: javac Salesperson (B).java
  Salesperson (B).java:35: error: 'else' without 'if'
  Salesperson (B).java:39: error: reached end of file while parsing
2 errors

----jGRASP wedge2: exit code for process is 1.
 ----jGRASP: operation complete.

With now, I have 2 errors, but not sure what to do now. It might be something small, but I don't see it, since I'm not familiar with what I'm suppose to be looking at. Please help

6 Months
Discussion Span
Last Post by JamesCherrill

You've got some parenthesis hanging around in suspicious places. Better round them up. Do that by going to each left parenthesis and see where its matching right side is.

One thing I recommend is eliminate a bit of Arrow-Code Anti-Pattern ( https://blog.codinghorror.com/flattening-arrow-code/ ) by getting rid of the easy possibilities first:
If differ is less than 0, you can return right away with the fixedSalary.
All the code after that can safely assume that differ is greater or equal to 0 (meaning the sales person met their quota).


Look at line 45. You have an extra ; that completely changes the meaning of that line of code, and therefore the meaning of what follows.

Edited by JamesCherrill

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.