Почему этот код не рассчитывает налог за вычетом дохода для распечатки зарплаты домой? Налоговая лаборатория - PullRequest
2 голосов
/ 29 мая 2020

Это должна быть простая налоговая лаборатория, но я застрял в подсчете доходов - налогов и печати результатов. Что я делаю не так?

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("Please select a filing status Below: \n1 for Single, 2 for Married ");

        int status = input.nextInt();

        //Get input for taxable income

        System.out.println("\nPlease Enter Your Income");

        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("\nFiling status: " + status + "\n" + " income: %9.2f" + "\n" + " tax: %12.2f" + "\n" + " TakeHome: %12.2f"); //Frack Try 1

         System.out.printf("\nFiling status: " + status + "\n" + " Your Gross Income is: %9.12f" + "\n" + " You must pay:  %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;
    }


}

1 Ответ

1 голос
/ 29 мая 2020

Похоже, что в вашем коде нет реализации следующего метода, который возвращает двойной ComputeedTakeHomePay (доход, - налог)

...