爲什麼工資裏面的價值是不是被從工資法解析,以委員會的方法?從方法傳遞價值的方法
package salesrepresentativeapp;
import java.util.Scanner;
/**
*
* @author Kirin
*/
public class SalesRepresentativeAPP {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String ID;
String name;
int yearServiced;
double salesVolume;
//System.out.println("Please enter your ID : ");
// ID = sc.nextLine();
// System.out.println("Please enter your Name : ");
// name = sc.nextLine();
System.out.println("Please enter your Year of Service : ");
yearServiced = sc.nextInt();
System.out.println("Please enter your sales volume : ");
salesVolume = sc.nextDouble();
SalesRepresentative s1 = new SalesRepresentative("id", "name", yearServiced, salesVolume);
//System.out.println("ID : " + s1.getID() + "\nName : " + s1.getName());
System.out.println("Your total salary is : " + s1.Commision() + "\nBasic Salary is : " + s1.Salary());
}
}
。
package salesrepresentativeapp;
/**
*
* @author Kiin
* v1.0
*/
public class SalesRepresentative {
private String ID;
private String name;
private int yearServiced,salary;
private double salesVolume,commision;
public SalesRepresentative(String ID, String name, int yearServiced, double salesVolume){
this.ID = ID;
this.name = name;
this.yearServiced = yearServiced;
this.salesVolume = salesVolume;
}
public int Salary(){
if (yearServiced >=1 && yearServiced <= 5) {
salary = 1200;
}
else if (yearServiced >=6 && yearServiced <= 10) {
salary = 1800;
}
else if (yearServiced > 10) {
salary = 2300;
}
return salary;
}
public double Commision(){
if (salesVolume >= 1 && salesVolume <= 99.99) {
commision = salary + (salary * 0.05);
}
else if (salesVolume >= 100.00 && salesVolume <= 299.99) {
commision = salary + (salary * 0.10);
}
else if (salesVolume >= 300.00) {
commision = salary + (salary * 0.15);
}
return commision;
}
public String getID(){
return ID;
}
public String getName(){
return name;
}
}
當我沒有把工資方程的方法效果很好英寸但是,當我把工資方程式裏面的方法的返回值0.0