英文:
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("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
在您的代码中似乎没有实现以下方法,该方法返回一个双精度数 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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论