2016-11-03 2 views
-1

계속 오류가 발생하고이를 수정하는 방법이 확실하지 않습니다. 스레드에서RuntimeException : 컴파일 할 수없는 소스 코드 (Netbeans)

예외 "주요"java.lang.RuntimeException가 : Uncompilable 소스 코드 - 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

클래스 변수와 메소드를 넣는다. 메인 메소드 외부에 정의가 있어야한다.

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

그러나 코드

당신이 main 메소드의 메소드 실행해야 이치에 맞지 않는다 : O)

0

이것은 넷빈즈 오류가 아닙니다을 ... 당신의 주요 방법은없는 닫힌 버팀대 :

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; 
} 
관련 문제