我是CompSci的新学生。我的意思是N00B。我有点想尽办法了,并且知道我在此税务实验室中缺少一些简单的东西。我整天都在努力。同样,我是N00B。
应该是一个简单的税收实验室,但我一直在计算收入-税收并打印结果。这里的所有帖子都非常简单,但我一直停留在此。我究竟做错了什么?我认为这很简单,但是我整天盯着屏幕看,只能看到失败。
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;
}
}
您的代码中似乎没有实现以下方法的实现,该实现返回双精度ComputeedTakeHomePay(income,-tax)]