所以我正在尝试计算国民保险,我正在使用 3 个 IF 语句。
/does not work
public double calculateNotContOut(){
if (calculateWeeklyEarning()<upperEarningLevel){
return (((calculateWeeklyEarning()-primaryThreshold)*primaryClassBetween)*52);
}
else {
return (((upperEarningLevel-primaryThreshold)*primaryClassBetween+(calculateWeeklyEarning()-upperEarningLevel)*primaryClassAbove)*52);
}
}
//does not work
public double calculateContOut(){
if (calculateWeeklyEarning()<upperEarningLevel){
return (((calculateWeeklyEarning()-primaryThreshold)*calculateReducedContribution())*52);
}
else{
return (((upperEarningLevel-primaryThreshold)*calculateReducedContribution()+(calculateWeeklyEarning()-upperEarningLevel)*primaryClassAbove)*52);
}
}
public double calculateNationalInsurance(){
if (contractedOut){
return (calculateContOut());
}
else {
return (calculateNotContOut());
}
}
它们不返回正确的值。有人可以帮忙吗?