有可执行代码

时间:2017-04-22 22:37:09

标签: 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-
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.
}

功能读取用户输入

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

}
}

1 个答案:

答案 0 :(得分:0)

可能是因为你的set.fixedSalary需要是一个整数,因为你没有将它设置为double。当需要36000.0

时,将其设置为36000