當我嘗試計算fedtax時出現錯誤。但它說它找不到符號。我嘗試過不同的事情,但我仍然得到同樣的錯誤。任何幫助,將不勝感激。在Java中的方法中找不到符號
public class calculatetax {
public static void main(String[ ] args) {
Scanner kb = new Scanner(System.in);
int employeehr = 0;
int ratehr = 0;
String stateresidence = "";
String maritalstatus = "";
System.out.println(" Employee Hours pls ") ;
employeehr = kb.nextInt();
System.out.println(" Hourly Rate ") ;
ratehr = kb.nextInt();
System.out.println(" State of residence") ;
stateresidence = kb.nextLine();
System.out.println("Marital Status") ;
maritalstatus = kb.nextLine();
int wages = calculatewages(employeehr,ratehr);
calculatefedax(wages,maritalstatus);
}
public static int calculatewages(int n1, int n2) {
int wages = n1 * n2;
System.out.println("Return Wages" + wages);
return wages;
}
public static double calculatefedtax(double fedtax, str maritalstatus) {
if(maritalstatus.equals("marry"))
{
fedtax = fedtax * .20;
}
else if (maritalstatus.equals("single"))
{
fedtax = fedtax * .25;
}
else
{
fedtax = fedtax * .22;
}
return fedtax;
}
}
'str maritalstatus'是一個錯字嗎? – John3136
它必須是錯字;代碼中的其他地方使用適當的類String。 – rgettman
什麼是「str」?不應該是字符串婚姻狀態? – user2573153