私はプロジェクトに取り組んでいて、立ち往生していて、しばらくの間、t2001 と t2009 の 2 つのオブジェクトを作成したいと考えています。それらのコンストラクターを TaxFiling にしましたが、シンボルが見つからないという赤い下線のエラーが引き続き表示されますか? 誰かが私が間違っていることを知っていますか?
package ProgrammingAssignment;
import java.util.Scanner;
/**
*
* @author Joe
*/
public class Tax {
public static final int SINGLE_FILER = 0;
public static final int MARRIED_JOINTLY_OR_QUALIFYING_WIDOW = 1;
public static final int MARRIED_SEPARATELY = 2;
public static final int HEAD_OF_HOUSEHOLD = 3;
private int filingStatus;
private int[][] brackets;
private double[] rates;
private double taxableIncome;
public Tax(int filingStatus, int[][] brackets, double[] rates, double taxableIncome) {
this.filingStatus = filingStatus;
this.brackets = brackets;
this.rates = rates;
this.taxableIncome = taxableIncome;
}
public double getTax() {
double tax;
if (taxableIncome <= brackets[filingStatus][0]) {
return Math.round(taxableIncome * rates[0]);
}
tax = brackets[filingStatus][0] * rates[0];
for (int i = 1; i < brackets[filingStatus].length; i++) {
if (taxableIncome > brackets[filingStatus][i]) {
tax += (brackets[filingStatus][i] - brackets[filingStatus][i - 1]) * rates[i];
} else {
return Math.round(tax + (taxableIncome - brackets[filingStatus][i - 1]) * rates[i]);
}
}
return Math.round(tax + (taxableIncome - brackets[filingStatus][4]) * rates[5]);
}
public void TaxFiling(int taxYear, int[][] brackets, double[] rates) {
int Year = taxYear;
int[][] bracket = brackets;
double[] rate = rates;
}
public static void main(String[] args) {
int taxYear;
int sIncome;
int eIncome;
int stepVal;
Scanner input = new Scanner(System.in);
System.out.println("Enter a tax year: ");
taxYear = input.nextInt();
if (taxYear != 2009 && taxYear != 2001) {
System.out.println("Please Enter a Valid Year!");
System.exit(1);
}
System.out.println("Enter the starting income value: ");
sIncome = input.nextInt();
System.out.println("Enter ending income value: ");
eIncome = input.nextInt();
if (eIncome < sIncome) {
System.out.println("Ending Income Cannot Be Less Then Starting");
System.exit(2);
}
System.out.println("Enter a step value: ");
stepVal = input.nextInt();
if (stepVal < 0) {
System.out.println("Please Enter a Positive Step Value!");
System.exit(3);
}
System.out.println(taxYear + " Tax Table");
System.out.println("Income range: " + sIncome + " to " + eIncome);
int[][] brackets2009 = new int[][]{
// stat 0 single
{8350, 33950, 82250, 171550, 372950},
// stat 1 Married Filing Jointly
{16700, 67900, 137050, 208850, 372950},
// stat 2 Married Filing Separately
{8350, 33950, 68525, 104425, 186475},
// stat 3 Head of Household
{11950, 45500, 117450, 190200, 372950}};
int[][] brackets2001 = new int[][]{
// stat 0 single
{27050, 65550, 136750, 297350},
// stat 1 married joint
{45200, 109250, 166500, 297350},
// stat 2 married separate
{22600, 54625, 83250, 148675},
// stat 3 head of household
{36250, 93650, 15150, 297350}
};
double[] rates2009 = new double[]{0.10, 0.15, 0.25, 0.28, 0.33, 0.35};
double[] rates2001 = new double[]{.15, .275, .305, .355, .391};
TaxFiling t2001 = new TaxFiling(2001, brackets2001, rates2001);
TaxFiling t2009 = new TaxFiling(2009, brackets2009, rates2009);
if (taxYear == 2001) {
DisplayTaxTable(t2001, sIncome, eIncome, stepVal);
} else if (taxYear == 2009) {
DisplayTaxTable(t2009, sIncome, eIncome, stepVal);
}
}
public static void displayTaxTable(Tax tObj, int incomeStart, int incomeEnd, int incomeStep) {
String s1 = "Taxable Income";
String s2 = "Single";
String s3 = "Married Joint";
String s4 = "Married Separate";
String s5 = "Head of house";
System.out.printf(
"%-20s%-12s%-4s%21s%16s\n", s1, s2, s3, s4, s5);
for (int i = 50000;
i <= 60000; i += 1000) {
System.out.printf("%4d%19.0f%16.0f%16.0f%20.0f\n", i,
new Tax(Tax.SINGLE_FILER, brackets2009, rates2009, i).getTax(),
new Tax(Tax.MARRIED_JOINTLY_OR_QUALIFYING_WIDOW, brackets2009, rates2009, i).getTax(),
new Tax(Tax.MARRIED_SEPARATELY, brackets2009, rates2009, i).getTax(),
new Tax(Tax.HEAD_OF_HOUSEHOLD, brackets2009, rates2009, i).getTax()
);
}
for (int i = 50000;
i <= 60000; i += 1000) {
System.out.printf("%4d%19.0f%16.0f%16.0f%20.0f\n", i,
new Tax(Tax.SINGLE_FILER, brackets2001, rates2001, i).getTax(),
new Tax(Tax.MARRIED_JOINTLY_OR_QUALIFYING_WIDOW, brackets2001, rates2001, i).getTax(),
new Tax(Tax.MARRIED_SEPARATELY, brackets2001, rates2001, i).getTax(),
new Tax(Tax.HEAD_OF_HOUSEHOLD, brackets2009, rates2001, i).getTax()
);
}
}
}