为什么这段代码没有计算税收减去收入以打印实际收入?税务实验室

huangapple go评论77阅读模式
英文:

Why does this code not calculate tax minus income to print take home pay? Tax Lab

问题

这是你的代码的翻译部分:

package com.company;
import java.util.Scanner;
public class Main {

// 税务实验

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Scanner input = new Scanner(System.in);

        // 获取报税状态

        System.out.println("请选择以下报税状态:\n1 为单身,2 为已婚 ");

        int status = input.nextInt();

        // 获取应税收入

        System.out.println("\n请输入您的收入");

        double income = input.nextDouble();

        // 计算税金

        double tax = computedTaxResult(status, income); // 这计算我的收入和婚姻状态

        // 计算实际收入

        //double TakeHomePay = ComputeedTakeHomePay(income, - tax);

        // 输出报税状态、收入和税金结果

        //System.out.printf("\nFiling status: " + status + "\n" + " income: %9.2f" + "\n" + " tax: %12.2f" + "\n" + " TakeHome: %12.2f"); //尝试 1

         System.out.printf("\n报税状态: " + status + "\n" + " 您的总收入是: %9.12f" + "\n" + " 您需要支付:  %12.2f");

                 System.exit(0);
    }


    public static double computedTaxResult(int status, double income){


        double computedTaxResult = 0;

        if (status == 1) {
            if (income <= 9325)
                computedTaxResult = (income * .10);

            else if (income <= 37950)
                computedTaxResult = (932.50 + (income - 27050) * .15);

            else if (income <= 91900)
                computedTaxResult = (14645.0 + (income - 65550) * .25);

            else if (income <= 191650)
                computedTaxResult = (36361 + (income - 136750) * .28);

            else if (income <= 416700)
                computedTaxResult = (36361 + (income - 136750) * .33);

            else if (income <= 418400)
                computedTaxResult = (36361 + (income - 136750) * .35);

            else computedTaxResult = (121505.25 + (income - 418400) * .39);
        }
        if (status == 2) {
            if (income <= 18650)
                computedTaxResult = (income * .10);

            else if (income <= 75000)
                computedTaxResult = (6780.0 + (income - 45200) * .15);

            else if (income <= 153100)
                computedTaxResult = (24393.75 + (income - 109250) * .25);

            else if (income <= 233350)
                computedTaxResult = (41855 + (income - 166500) * .28);
            else if (income <= 416700)
                computedTaxResult = (52222.50 + (income - 166500) * .33);
            else if (income <= 470700)
                computedTaxResult = (112728 + (income - 166500) * .35);
            else if (income > 470700)
             computedTaxResult = (131628 + (income - 297350) * .396);
        }


        return computedTaxResult;
    }


}
英文:

It's supposed to be a simple tax lab, but I'm stuck calculating Income - Tax and printing the result. What am I doing wrong?

package com.company;
import java.util.Scanner;
public class Main {
// IRS Take Home Pay Lab
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
//Get input for filing status
System.out.println(&quot;Please select a filing status Below: \n1 for Single, 2 for Married &quot;);
int status = input.nextInt();
//Get input for taxable income
System.out.println(&quot;\nPlease Enter Your Income&quot;);
double income = input.nextDouble();
//Compute tax
double tax = computedTaxResult(status, income); // this computes my income and marital status
// computing take home pay
//double TakeHomePay = ComputeedTakeHomePay(income, - tax);
//Output filing status, income, and tax result
//System.out.printf(&quot;\nFiling status: &quot; + status + &quot;\n&quot; + &quot; income: %9.2f&quot; + &quot;\n&quot; + &quot; tax: %12.2f&quot; + &quot;\n&quot; + &quot; TakeHome: %12.2f&quot;); //Frack Try 1
System.out.printf(&quot;\nFiling status: &quot; + status + &quot;\n&quot; + &quot; Your Gross Income is: %9.12f&quot; + &quot;\n&quot; + &quot; You must pay:  %12.2f&quot;);
System.exit(0);
}
public static double computedTaxResult(int status, double income){
double computedTaxResult = 0;
if (status == 1) {
if (income &lt;= 9325)
computedTaxResult = (income * .10);
else if (income &lt;= 37950)
computedTaxResult = (932.50 + (income - 27050) * .15);
else if (income &lt;= 91900)
computedTaxResult = (14645.0 + (income - 65550) * .25);
else if (income &lt;=191650)
computedTaxResult = (36361 + (income - 136750) * .28);
else if (income &lt;=416700)
computedTaxResult = (36361 + (income - 136750) * .33);
else if (income &lt;=418400)
computedTaxResult = (36361 + (income - 136750) * .35);
else computedTaxResult = (121505.25 + (income - 418400) * .39);
}
if (status == 2) {
if (income &lt;= 18650)
computedTaxResult = (income * .10);
else if (income &lt;= 75000)
computedTaxResult = (6780.0 + (income - 45200) * .15);
else if (income &lt;= 153100)
computedTaxResult = (24393.75 + (income - 109250) * .25);
else if (income &lt;= 233350)
computedTaxResult = (41855 + (income - 166500) * .28);
else if (income &lt;= 416700)
computedTaxResult = (52222.50 + (income - 166500) * .33);
else if (income &lt;= 470700)
computedTaxResult = (112728 + (income - 166500) * .35);
else if (income &gt; 470700)
computedTaxResult = (131628 + (income - 297350) * .396);
}
return computedTaxResult;
}
}

答案1

得分: 1

在您的代码中似乎没有实现以下方法,该方法返回一个双精度数 ComputeedTakeHomePay(income, - tax)

英文:

There does not appear to be an implementation in your code of the following method that returns a double ComputeedTakeHomePay(income, - tax)

huangapple
  • 本文由 发表于 2020年5月29日 12:25:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/62078719.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定