2016-11-03 6 views
-1

これは私が得ているエラーで、修正方法は不明です。RuntimeException:コンパイル不可能なソースコード(Netbeans)

スレッドの例外 "メイン" java.lang.RuntimeException:互換性のない ソースコード - での発現の違法開始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; 
    } 
} 

答えて

0

クラス変数とメソッドを定義するmainメソッドの外で定義すればうまくいくはずです。

1

二重手数料の後に「}」を単に忘れると、 :-)

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

しかし、その後コード

はあなたが主な方法でメソッドを実行する必要が意味をなさない:O)

0

これは、NetBeansのエラーではありませんが...あなたの主な方法はありません。閉じたブレース:

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; 
} 
関連する問題