我的作业是为一家正在补充库存的珠宝店计算税金和附加费,我遇到了一个小问题。我正在使用一种名为 calcExtraTax 的方法三次来计算劳动率以及州和联邦税。然后,我需要获取该方法的每个实例的结果,并将值传递给我的 main 方法中的适当变量。这就是我的代码现在的样子(显然不完整):
import java.text.DecimalFormat;
import java.util.Scanner;
import javax.swing.JOptionPane;
public static void main(String[] args)
{
double stateRate = 0.1;
double luxuryRate = 0.2;
double laborRate = 0.05;
double extraCharge;
int numOrdered;
double diamondCost;
double settingCost;
double baseCost;
double totalCost;
double laborCost;
double stateTax;
double luxuryTax;
double finalAmountDue;
Scanner keyInput = new Scanner(System.in);
System.out.println("What is the cost of the diamond?");
diamondCost = keyInput.nextDouble();
System.out.println("What is the cost of the setting?");
settingCost = keyInput.nextDouble();
System.out.println("How many rings are you ordering?");
numOrdered = keyInput.nextInt();
baseCost = diamondCost + settingCost;
calcExtraCost(baseCost, laborRate);
laborCost = extraCharge;
calcExtraCost(baseCost, stateRate);
stateTax = extraCharge;
calcExtraCost(baseCost, luxuryRate);
luxuryTax = extraCharge;
totalCost = baseCost + laborCost + stateTax + luxuryTax;
finalAmountDue = numOrdered*totalCost;
JOptionPane.showMessageDialog(null, "The final amount due is = " + finalAmountDue);
}
public static void calcExtraCost(double diamond, double rate)
{
double extraCharge = diamond*rate;
???????????
}
我想弄清楚的是我还需要在我的辅助方法中添加什么,以便能够每次根据公式中使用的费率变量将结果传递到不同的税收成本变量中。