Java 需要有可执行代码方面的帮助吗
我无法使此代码对类可执行,也找不到没有错误提示的原因。但是,当我执行时,我得到以下信息:Java 需要有可执行代码方面的帮助吗,java,Java,我无法使此代码对类可执行,也找不到没有错误提示的原因。但是,当我执行时,我得到以下信息: Exception in thread "main" java.lang.UnsupportedOperationException: Not supported yet. at set.fixedSalary(set.java:14) at Main.main(Main.java:23) C:\Users\the_h\AppData\Local\NetBeans\Cache\8.2\executor-
Exception in thread "main" java.lang.UnsupportedOperationException: Not
supported yet.
at set.fixedSalary(set.java:14)
at Main.main(Main.java:23)
C:\Users\the_h\AppData\Local\NetBeans\Cache\8.2\executor-
snippets\run.xml:53: Java returned: 1
我真的不知道如何解决这个问题任何帮助是感谢我有下面的源代码
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
private double fixedSalary;
private double commission;
private double salesTarget;
private double Acc_Rate;
private ArrayList<Double> annualSales;
private ArrayList name;
public static void main(String[] args){
// salesperson will earn a fixed salary of $32,600
set.fixedSalary(32600);
// The current sales target for every salesperson is $120,000.00
set.SalesTarget(120000.00);
//The acceleration factor is 2.1
set.Acc_Rate(2.1);
}
public ArrayList<Double> getAnnualSales(){
return annualSales;
}
public Main() {
this.name = new ArrayList();
this.annualSales = new ArrayList<>();
}
private float calculateCommission(double personSale) {
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
类计算委员会{
双倍佣金=0.00;
双Acc_比率;
计算委员会(){
}
公共双倍计算委员会(双倍年销售额、双倍固定工资、,
双倍销售目标){
该年销售率=0.045*年销售率;
双倍收入=固定工资;
//目前的佣金是总销售额的4.5%
如果(年销售额<0.8*销售目标){
收入=固定工资+佣金;
}其他如果(年度销售目标){
收入=固定工资+会计费率;
}
收益;
}
}//函数get commission
公共事务委员会(){
退货佣金;
}
//函数获得年度总薪酬
公共双getTotalCommissionCalc(){
返回固定工资+获取佣金();
}
//固定工资的功能设置值
公共作废设置固定工资(双倍固定工资){
this.fixedSalary=fixedSalary;
}
//salesTarget的函数设置值
public void setSalesTarget(双重salesTarget){
this.salesTarget=salesTarget;
}
//激励率的函数设定值
公共无效设置附加率(双重附加率){
此。Acc_率=Acc_率;
}
//显示潜在年度薪酬总额的表格
public void displayResult(){
双年鉴;
双重人格;
对于(int i=0;iannualSales.get(0)){
System.out.println(“销售人员”+name.get(0)
+“他必须增加的销售额”
+“达到或超过销售人员中的较高者
"
+数学圆(annualSales.get(1))+“是”);
系统输出打印(“$”+数学圆整((年度销售获取(1)——
年销售量(0);
}否则{
系统输出打印(“两者具有相同的补偿”);
}
}
}
这可能是因为set.fixedSalary需要为整数,因为您没有将其设置为双精度。当需要为36000.0时,将其设置为36000FixcalculateCommission
。它正在运行,但您还没有编写该方法。您的calculateCommission
方法显式抛出了该异常。我看到calculateCommission有一个double,并删除了其中一个,但我仍然得到了错误
class readData{
public void readData(){
// Creates a scanner object for sales entry.
Scanner input = new Scanner(System.in);
// prompts user for name of sales person
System.out.println("Please enter First Sales Person name: ");
name = addinput.nextLine();
// prompts user for name of sales person
System.out.println("Please enter 2nd Sales Person name: ");
name = addinput.nextLine();
//Prompts user for sales
System.out.println("Please enter annual sales First Person: ");
annualSales = addinput.nextDouble();
//Prompts user for sales
System.out.println("Please enter annual sales Second Person: ");
annualSales = addinput.nextDouble();
}
}
class calculateCommission {
double commission = 0.00;
double Acc_Rate;
calculateCommission() {
}
public double calculateCommission(double annualSales, double fixedSalary,
double salesTarget) {
this.Acc_Rate = 0.045 * annualSales;
double earnings = fixedSalary;
// The current commission is 4.5 of total sales
if(annualSales < 0.8 * salesTarget) {
earnings = fixedSalary + commission;
} else if (annualSales <= salesTarget){
//The current acc rate is 2.1 of total sales
commission = 0.045 * annualSales;
earnings = fixedSalary + commission;
} else if (annualSales > salesTarget){
earnings = fixedSalary + Acc_Rate;
}
return earnings;
}
} // function get commision
public double getCommission() {
return commission;
}
// function get total annual compensation
public double getTotalCommissionCalc(){
return fixedSalary + getCommission();
}
// funtion set value for fixedSalary
public void setfixedSalary(double fixedSalary){
this.fixedSalary = fixedSalary;
}
// funtion set value for salesTarget
public void setSalesTarget(double salesTarget){
this.salesTarget = salesTarget;
}
// funtion set value for incentive rate
public void setAcc_Rate(double Acc_Rate) {
this.Acc_Rate = Acc_Rate;
}
// Display a table of potential total annual compensation
public void displayResult(){
double annualSalesCalc;
double personSale;
for (int i = 0; i < name.size(); i++){
String personName = (String) name.get(i);
personSale = annualSales.get(i);
System.out.println("Total Compensation of Sales Person " +
personName + " is " + Math.round(calculateCommission(personSale)));
//Print column names
System.out.print("SalePerson\tTotal Sales\tTotal Compensation");
annualSalesCalc = personSale * 1.50;
while(personSale <= annualSalesCalc){
calculateCommission(personSale);
System.out.println((personName) + "\t\t" +
Math.round((personSale)) + "\t\t" +
Math.round(calculateCommission(personSale)));
personSale = personSale + 5000;
}
System.out.println(); // print blank line
}
if (annualSales.get(0) > annualSales.get(1)) {
System.out.println("Salesperson " + name.get(1)
+ "'s additional amount of sales that he must "
+ "achieve to match or exceed the higher of the salesperson
"
+ Math.round(annualSales.get(0)) + " is");
System.out.print("$" + Math.round((annualSales.get(0) -
annualSales.get(1))));
} else if(annualSales.get(1) > annualSales.get(0)){
System.out.println("Salesperson " + name.get(0)
+ "'s additional amount of sales that he must "
+ "achieve to match or exceed the higher of the salesperson
"
+ Math.round(annualSales.get(1)) + " is");
System.out.print("$" + Math.round((annualSales.get(1) -
annualSales.get(0))));
} else{
System.out.print("Both have same compensation");
}
}
}