Newb Java 程序员在这里,为什么这个计算器不计算?
该程序应输入用户的收入,然后根据计算输出他们的联邦税。
联邦税收规则: 前 45,282 美元的应税收入的 15%,接下来的 45,281 美元的应税收入的 20.5%(超过 45,282 美元的应税收入高达 90,563 美元的部分),接下来的 49,825 美元的应税收入的 26%(在应税收入超过 90,563 美元至 140,388 美元的部分),+
输入:
Enter 标记:85
输出:
等级是:A
输入:
Enter 标记:110
输出:
输入一个介于 0 和 100 之间的值
输入:
Enter 标记:79.5
输出:
等级是:B+
输入:
Enter 标记:-10
输出:
输入 a价值在 0 到 100 之间 下一个 59,612 美元的应税收入(超过 140,388 美元至 200,000 美元的应税收入部分)的 29%,+ 超过 200,000 美元的应税收入的 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;
}
}
}
}