Newb Java程序员在这里,
为什么这个计算器没有计算?
程序应该输入用户的收入,然后根据计算结果输出他们的联邦税。
联邦税收规则:
第一笔45,282美元的应纳税所得额为+ 15%
未来45.281美元的应纳税所得额(应纳税所得额超过45,282美元的部分为20.5%)
$ 90,563),+
未来应税收入49,825美元的26%(应税收入超过90,563美元的部分)
140,388美元),+
输入:
输入标记:85
输出:
等级是:A
输入:
输入标记:110
输出:
输入介于0和100之间的值
输入:
输入标记:79.5
输出:
等级是:B +
输入:
输入标记:-10
输出:
输入介于0和100之间的值
下一个应税收入59,612美元的29%(应税收入超过140,388美元的部分)
$ 200,000),+
应税收入超过20万美元的33%。
package practiceproblab4;
import java.util.Scanner;
/**
*
* @author JAVA NEWB
*/
public class PracticeProbLab4 {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter your Income: ");
String In = sc.nextLine();
Double Income = Double.parseDouble(In);
calculateAndPrintTax(Income);
System.out.println("Your taxes are: " + TotalTax);
}
static double calculateAndPrintTax(double Income, double Tax)
{
double tax;
double difftax1;
double difftax2;
double difftax3;
double difftax4;
double TotalTax;
if ((Income >= 45282) && (Income <= 200000))
{
if(Income<=45282)
{
tax = 45282 * 0.15;
TotalTax = tax;
}
else if (Income > 45282 && Income <= 90653)
{
tax = 45282 * 0.15;
difftax1 = (Income - 45282)* .205;
TotalTax = tax + difftax1;
}
else if ((Income >90563) && (Income <= 140388))
{
tax = 45282 * 0.15;
difftax1 = (Income - 45282) * .205;
difftax2 = (Income - 90563) * 0.26;
TotalTax = tax + difftax1 + difftax2;
}
else if ((Income > 140388) && (<= 200000))
{
tax = 45282 * 0.15;
difftax1 = (Income - 45282) * .205;
difftax2 = (Income - 90563) * 0.26;
difftax3 = (Income - 140388) * 0.29;
TotalTax = tax + difftax1 + difftax2 + difftax3;
}
else if ((Income > 200000))
{
tax = 45282 * 0.15;
difftax1 = (Income - 45282) * .205;
difftax2 = (Income - 90563) * 0.26;
difftax3 = (Income - 140388) * 0.29;
difftax4 = (Income - 200000) * 0.33;
TotalTax = tax + difftax1 + difftax2 + difftax3 + difftax4;
}
else ((Income > 200000))
{
tax = 45282 * 0.15;
difftax1 = (Income - 45282) * .205;
difftax2 = (Income - 90563) * 0.26;
difftax3 = (Income - 140388) * 0.29;
difftax4 = (Income - 200000) * 0.33;
TotalTax = tax + difftax1 + difftax2 + difftax3 + difftax4;
return TotalTax;
}
}
}
}