请各位高手不吝赐教,JAVA程序问题

 总共两个文件TaxTest.java与Tax.java

---------------------------------------------------------------------------------------

TaxTest.java

===========================================

import javax.swing.JOptionPane; public class TestTax{ public static void main(String[] args){ String yearString = JOptionPane.showInputDialog("Enter the year ,etc 2001 or 2002"); int year = Integer.parseInt(yearString); Tax change = new Tax(); change.setBrackets(year); change.setRates(year); int[][] brackets = change.getBrackets(); double[] rates = change.getRates(); double taxableIncome = change.getTaxableIncome(); double tax = 0; System.out.println(year + " year Ameica duty of four persons"); System.out.println("-----------------------------------------------------"); System.out.println("taxableIncome SINGLE_FILER MARRIED_JOINTLY MARRIED_SEPARATELY HEAR_OF_HOUSHOLD"); System.out.println("-----------------------------------------------------"); for(double i = taxableIncome;i <= 60000;){ System.out.println(taxableIncome ); for(int filingStatus = 0;filingStatus <= 3;filingStatus ++){ if(taxableIncome <= brackets[filingStatus][0]) tax = taxableIncome * rates[0]; else tax = brackets[filingStatus][0] * rates[0]; for(int j = 1;j < brackets[0].length;j ++){ if(taxableIncome < brackets[filingStatus][j]) tax += (brackets[filingStatus][j]-brackets[filingStatus][j-1])*rates[j]; else tax += (taxableIncome -brackets[filingStatus][j-1])*rates[j]; } System.out.println(" " + tax); } taxableIncome += 1000; System.out.println(); } System.out.println("-----------------------------------------------------"); } }

 

Tax.java

=============================================

public class Tax{ private int filingStatus = 0; private int[][] brackets; private double[] rates; private double taxableIncome; public Tax(){} public Tax(int filingStatus,int[][] brackets,double[] rates,double taxableIncome){ this.filingStatus = filingStatus; this.brackets = brackets; this.rates = rates; this.taxableIncome = taxableIncome; } public static void setFilingStatus(int filingStatus){ filingStatus ++; } public int getFilingStatus(){ return filingStatus; } public void setBrackets(int year){ if (year == 2001) brackets[][]={{27050,65550,136750,297350},{45200,109250,166500,297350},{22600,54625,83250,148675},{36250,93650,151650,297350}}; else brackets[][]={{6000,27950,67700,141250,307050},{12000,46700,112850,171950,307050},{6000,23350,56425,85975,153525},{10000,37450,96700,156600,307050}}; } public int[][] getBrackets(){ return brackets; } public void setRates(int year){ if(year == 2001) rates[] = {0.150,0.275,0.305,0.355,0.391}; else rates[] = {0.100,0.150,0.270,0.300,0.350,0.386}; } public double[] getRates(){ return rates; } public void setTaxableIncome(double taxableIncome){ taxableIncome = 50000; this.taxableIncome = taxableIncome; } public double getTaxableIncome(){ return taxableIncome; } }

 

   请各位帮忙,谢谢了!

你可能感兴趣的:(请各位高手不吝赐教,JAVA程序问题)