Java陷入了这项任务的一部分

时间:2015-08-16 03:39:02

标签: java

这是我的任务:

  

使用Java™NetBeans™IDE修改第二周Java™应用程序,以满足这些额外和变更的业务要求:
   - 该公司最近改变了年度薪酬总额,以提高销售额    - 销售人员将继续获得75,000美元的固定工资。每个销售人员目前的销售目标是140,000美元    - 销售激励仅在满足80%的销售目标时开始。目前的佣金占总销售额的25%    - 如果销售人员超过销售目标,佣金将根据加速因子增加。加速因子为1.25    - 申请应要求用户输入年度销售额,并应显示年度总薪酬    - 申请还应显示销售人员可能获得的潜在年度总薪酬表,比销售人员的年销售额高出5000美元,直至达到销售人员年销售额的50%以上。

一切正常,我唯一能做到的就是让餐桌达到销售人员年销售额的50%。因此,例如,如果总销售额为100,000美元,则表格将显示总销售额和薪酬,直到150,000

这是源代码

DriverCalculator.java

import java.util.Scanner;


public class DriverCalculator {
    public static void main(String args[]){
        double annualSales;
        SalesPerson person;
        Scanner input=new Scanner(System.in);
        System.out.print("Please enter your total sales for the year: ");
        annualSales=input.nextDouble();
        person=new SalesPerson(annualSales);
        System.out.println(" Your total compensation for the year: $"+String.format("%.2f", person.getTotalAnnualCompensation()));

        System.out.println("Total Sales              Total Compensation");
        annualSales= annualSales;
        for(int i=0;i<11;i++){
            person=new SalesPerson(annualSales);
             System.out.println("$"+ annualSales+"                "+"$"+String.format("%.2f", person.getTotalAnnualCompensation()));
            annualSales+=5000;
        }
    }
}

SalesPerson.java

public class SalesPerson {
// create variable (fixedSalary)
 double fixedSalary;
 // variable of the value of sale person's annual sales
 double  annualSales;
 //commission that is earned
 double commission;
 //The target for sales that must be reached by sales person
 double target;
 public SalesPerson(double annualSales){
     this.annualSales=annualSales;
     target=140000;
     commission=0;
     if(annualSales>target*0.8){
        if(annualSales<target)commission=0.25*annualSales;//The current commission 25% of total sales.
        else commission=0.25*1.25*annualSales;//The current commission (0.25*1.25)% of total sales.
     }
     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 个答案:

没有答案