Я делаю таблицу налогов, и все работает правильно. Однако у меня возникают проблемы с расстоянием в теле стола. Интервал под облагаемым налогом доходом, одиночная и женатая совместная или квалифицирующая вдова (э-э) прекрасна, но когда я добираюсь до раздельного брака и главы семьи, промежуток времени отключается. Любая идея, что я могу сделать, чтобы исправить это? Это то, что я до сих пор:Интервал на таблице налогов Java
//this program prints a tax table
public class PrintTaxTable {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
//create table header
System.out.printf("%5s%12s%20s%12s%12s\n", "Taxable", "Single",
"Married Joint" , "Married", "Head of");
System.out.printf("%5s%20s%12s%12s%12s\n", "Income", "",
"or Qualifying", "Separate", "a house");
System.out.printf("%20s%15s%12s%20s%20s\n", "", "Widow(er)","", "","");
System.out.println("------------------------------------------------" +
"-----------------");
// Display table body
double taxableIncome = 50000;
while (taxableIncome <= 60000){
System.out.printf("%5.0f", taxableIncome);
for (int status = 0; status < 4; status++) {
// Display the product and align properly
System.out.printf("%12.0f", computetax(status, taxableIncome));
}
System.out.println("");
taxableIncome = taxableIncome + 50;
}
}
//compute all of the tax rates
public static double computetax(int status, double taxableIncome) {
double tax = 0;
if (status == 0) {
if (taxableIncome <= 8350)
tax = taxableIncome * 0.10;
else if (taxableIncome <= 33950)
tax = 8350 * 0.10 + (taxableIncome - 8350) * 0.15;
else if (taxableIncome <= 82250)
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(taxableIncome - 33950) * 0.25;
}
else if (status == 1) {
if (taxableIncome <= 16700)
tax = taxableIncome * 0.10;
else if (taxableIncome <= 67900)
tax = 16700 * 0.10 + (taxableIncome - 16700) * 0.15;
}
else if (status == 2) {
if (taxableIncome <= 8350)
tax = taxableIncome * 0.10;
else if (taxableIncome <= 33950)
tax = 8350 * 0.10 + (taxableIncome - 8350) * 0.15;
else if (taxableIncome <= 68525)
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(taxableIncome - 33950) * 0.25;
}
else if (status == 3) {
if (taxableIncome <= 11950)
tax = taxableIncome * 0.10;
else if (taxableIncome <= 45500)
tax = 11950 * 0.10 + (taxableIncome - 11950) * 0.15;
else if (taxableIncome <= 117450)
tax = 11950 * 0.10 + (45500 - 11950) * 0.15 +
(taxableIncome - 45500) * 0.25;
}
return tax;
}
}
спасибо, что исправили проблему отступы у меня был. – sarahm