0
林。這是程序,編譯器說這個問題在最後一行,但我無法弄清楚。錯誤:類接口或枚舉預期:類接口或枚舉使用Java和不斷收到錯誤預期
public class Ch3_PrExercise6
{
static Scanner console = new Scanner (System.in);
public static void main(String [] args)
throws Exception
{
final double FEDERAL_TAX_RATE = 0.15;
final double STATE_TAX_RATE = 0.035;
final double SOCIAL_SECURITY_TAX_RATE = 0.575;
final double MEDICARE_MEDICAID_TAX_RATE = 0.0275;
final double PENSION_PLAN = 0.05;
final double HEALTH_INSURANCE = $75;
String name;
double GrossAmount;
double FederalTax;
double StateTax;
double SocialSecurityTax;
double MedicareMedicaidTAx;
double PensionPlan;
double HealthInsurance;
double NetPay;
system.out.print("Bill Robinson");
name = console.nextline();
system.out.println();
system.out.println(name);
grossAmount = console.nextDouble();
federalTAx = grossAmount * FEDERAL_TAX_RATE;
stateTax= grossAmount * STATE_TAX_RATE;
SocialSecurityTax = grossAmount * SOCIAL_SECURITY_TAX_RATE;
MedicareMedicaidTax = grossAmount * MEDICARE_MEDICAID_TAX_RATE;
PensionPlan = grossAmount * PENSION_PLAN_RATE;
HealthInsurance = $75;
NetPay= grossAmount - federalTax - stateTax - SocialSecurityTax - MedicareMedicaidTax - PensionPlan - HealthInsurance;
PrintWriter outfile = new Printwriter("Ch3_Ex6out.txt");
outFile.printf ("Bill Robinson");
outFile.printf ("%n grossAmounT: $%8.2F");
outFile.printf ("%n federalTax $%8.2F");
outFile.printf ("%n stateTax $%8.2F");
outFile.printf ("%n SocialSecurityTax $%8.2F");
outFile.printf ("%n MedicareMedicaidTax $%8.2F");
outFile.printf ("%n Pension Plan $%8.2F");
outFile.printf ("%n HealthInsurance $%8.2F");
outFile.printf ("%n NetPay $%8.2F");
outFile.close();
}
}
}
你必須在這個文件中不止一個問題。例如75美元在這裏無效。你不能使用system.out.println();喜歡這個。看看「S」應爲「S」,在系統 – Jabir
開始看起來像你有一個太多的花括號太 – sjr
你必須確保你的變量名稱統一使用。你有一個被定義爲'GrossAmount'(大寫字母G),但稍後你將它用作'grossAmount'(小寫字母G)。 – David