-1

This is the error I keep getting and unsure how to correct it.

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - illegal start of expression at salescommission.SalesCommission.main(SalesCommission.java:27)

/*
 * 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 salescommission;

/**
 *
 * @author Michael
 */
public class SalesCommission {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args){
        // public class  SalesCommission {
    // fixed salary variable
     double fixedSalary;
     // variable of the value of sale person's annual sales
     double  annualSales;
     //the commission earned
     double commission;


    private final double annualSales;
    private double commission;
    private double fixedSalary;
     public SalesCommission(double annualSales){
         this.annualSales=annualSales;
        double commission = 0.25*annualSales; //The current commission 25% of total sales.
        int fixedSalary = 75000; // set fixed salary is 75000$
     }
     public double getTotalAnnualCompensation(){// calculate The total annual compensation is the fixed salary plus the commission earned
         return fixedSalary+commission;
     }
}
Tunaki
  • 132,869
  • 46
  • 340
  • 423

3 Answers3

1

You simply forget a "}" after double commission; :-)

/*
 * 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 salescommission;

/**
 *
 * @author Michael
 */
public class SalesCommission {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // public class  SalesCommission {
        // fixed salary variable
        double fixedSalary;
        // variable of the value of sale person's annual sales
        double annualSales;
        //the commission earned
        double commission;
    }
    private final double annualSales;
    private double commission;
    private double fixedSalary;

    public SalesCommission(double annualSales) {
        this.annualSales = annualSales;
        double commission = 0.25 * annualSales; //The current commission 25% of total sales.
        int fixedSalary = 75000; // set fixed salary is 75000$
    }

    public double getTotalAnnualCompensation() {// calculate The total annual compensation is the fixed salary plus the commission earned
        return fixedSalary + commission;
    }
}

But then the code make no sense you have to run a method in the main method :o)

5im
  • 224
  • 2
  • 13
0

Put class variables and method Definitions outside of main method then it should work.

R.Eduard
  • 26
  • 5
0

This is not a Netbeans error... your main method does not have a closed brace :)

public static void main(String[] args) {
    // public class  SalesCommission {
    // fixed salary variable
    double fixedSalary;
    // variable of the value of sale person's annual sales
    double annualSales;
    //the commission earned
    double commission;
}
fassoline
  • 191
  • 1
  • 1
  • 6