我试图做一个incometax程序并继续得到其中的14个错误。 请帮忙。
/*
*Printing IncomeTax
*9/7/15
*/
import java.util.Scanner;
public class IncomeTax
{
public static void main(String[] args);
{
Scanner keyboard = new Scanner(System.in);
System.out.print("---Income Tax Program---\n\n\n");
System.out.print("Your income:");
double income = keyboard.nextDouble();
System.out.print("Enter your filling status(S-Single,M-Married,J-JointlyFiling");
char filing=keyboard.next().charAt(0);
System.out.print("Enter the number of deductions you are claiming:");
int deductions = keyboard.nextInt();
double taxableIncome = taxableIncome(income,deductions);
double taxPercent = taxPercent(filingStatus,taxIncome);
double owedAmount = taxableIncome*taxPercent;
double takeHome= income-owedAmount;
double taxPercent2=taxPercent*100;
System.out.print("Income tax Information: ");
System.out.printf("\nIncome- %.2f",income);
System.out.print("Filing status:"+filing);
System.out.printf("Taxable Income- %.2f",taxabeIncome);
System.out.printf("Tax percentage:"+taxPercent1+"%");
System.out.printf("Tax owed: "+owedAmount);
System.out.printf("Take Home: "+takeHome);
}
}
public static double taxableIncome(double income,double deductions)
{
double taxIncome = income-5000-1000*deductions;
if (income>0)
return taxableIncome;
else
return 0;
}
public static double taxPercent(char filingStatus,double taxableIncome)
{
double taxPercent
if (taxIncome<=30000 && taxIncome>=0)
else if(filingStatus==S)
return==.05;
else if (filingStatus==M)
return==.08;
else ( filing status==J)
return==.10;
}
{
if (taxIncome<L=50000 && taxIncome>30000)
else if ( filingStatus == S)
return==.10;
else if(filingStatus == M)
return==.16;
else (filingStatus==J)
return==.20;
}
{
if (taxIncome>50000)
else if(filingStatus == S)
return==.20;
else if (filingStatus == M)
return ==.24;
else (filingStaus == J)
return==.30;
}
--------------------配置:-------------------- C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:41:错误:类,接口, 或枚举预期的公共静态双重应税收入(双倍 收入,双倍扣除) ^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:44:错误:类,接口或枚举预期if(income&gt; 0)^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:46:错误:类,接口, 或枚举预期其他^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:49:错误:类,接口, 或枚举预期} ^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:50:错误:类,接口, 或枚举预期公共静态双重税率(char filingStatus,double taxable收入) ^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:57:错误:类,接口或枚举预期 否则if(filingStatus == M) ^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:59:错误:类,接口或枚举预期 别的(备案状态== J) ^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:61:错误:类,接口或枚举预期} ^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:67:错误:类,接口, 或枚举预期 否则if(filingStatus == M) ^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:69:错误:类,接口或枚举预期 else(filingStatus == J) ^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:71:错误:类,接口或枚举预期 } ^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:77:错误:类,接口或枚举预期 否则if(filingStatus == M) ^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:79:错误:类,接口或枚举预期 else(filingStaus == J) ^ C:\ Users \ Tazeen \ Downloads \ IncomeTax.java:81:错误:类,接口或枚举预期} ^ 14错误
流程已完成。
答案 0 :(得分:0)
该方法不在课堂上;把它移到第二个大括号内。
对不起,这段代码很乱。这有什么不妥。
你似乎不够关心你正在做什么。要么今天开始关注或放弃编码。
/*
*Printing IncomeTax
*9/7/15
* @link https://stackoverflow.com/questions/33070915/class-interface-or-enum-expected-14-errors/33070940#3307094010
*/
import java.util.Scanner;
public class IncomeTax {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("Your income:");
double income = keyboard.nextDouble();
System.out.print("Enter your filling status(S-Single,M-Married,J-JointlyFiling");
char filingStatus = keyboard.next().charAt(0);
System.out.print("Enter the number of deductions you are claiming:");
int deductions = keyboard.nextInt();
double taxableIncome = getTaxableIncome(income, deductions);
double taxPercent = getTaxPercent(filingStatus, taxableIncome);
double owedAmount = taxableIncome * taxPercent;
double takeHome = income - owedAmount;
double taxPercent1 = taxPercent * 100;
System.out.println("Income tax Information: ");
System.out.println("Income: " + income);
System.out.println("Filing status: " + filingStatus);
System.out.println("Taxable Income: " + taxableIncome);
System.out.println("Tax percentage: " + taxPercent1);
System.out.println("Tax owed: " + owedAmount);
System.out.println("Take Home: " + takeHome);
}
public static double getTaxableIncome(double income, int numDeductions) {
double taxableIncome = income - 5000 - 1000 * numDeductions;
return (taxableIncome > 0.0 ? taxableIncome : 0.0);
}
public static double getTaxPercent(char filingStatus, double taxableIncome) {
double taxPercent = 0.0;
if (taxableIncome >= 0 && taxableIncome <= 30000) {
if (filingStatus == 'S') {
taxPercent = .05;
} else if (filingStatus == 'M') {
taxPercent = .08;
} else if (filingStatus == 'J') {
taxPercent = .10;
} else {
throw new IllegalArgumentException("Unknown tax percent");
}
} else if (taxableIncome > 30000 && taxableIncome <= 50000) {
if (filingStatus == 'S') {
taxPercent = .10;
} else if (filingStatus == 'M') {
taxPercent = .16;
} else if (filingStatus == 'J') {
taxPercent = .20;
}
} else if (taxableIncome > 50000) {
if (filingStatus == 'S') {
taxPercent = .20;
} else if (filingStatus == 'M') {
taxPercent = .24;
} else if (filingStatus == 'J') {
taxPercent = .30;
}
}
return taxPercent;
}
}