我似乎無法讓我打印的表格停止在60.000,因爲它是與之相關的。 印刷永遠不會讓我相信我已經創造了一個無限的循環.. 理想是打印一張表,賦予價值在四種填充類型50000和60000價值稅和每增加50排...我想用雙重方法打印一張桌子..但不工作
public class FinantialAplicationTable {
public static void main(String[] args) {
int status=0;
double taxableIncome=0;
System.out.printf("Taxable Income\tSingle\tMarried Filling Jointly\tMarried Filling Sepratly\tHead Of Household\n");
System.out.printf(" or Qualifing Widower\n");
System.out.print("______________________________________________________________________________________________________\n");
printTable(status,taxableIncome);
}
public static double printTable(int status, double taxableIncome){
double tax1,tax2,tax3,tax4;
for (taxableIncome=50000;taxableIncome<60000;taxableIncome =taxableIncome+50){
tax1 = 8350*0.10+(33950-8350)*0.15+(taxableIncome-33950);
tax2 = 16700*0.10+(taxableIncome-16700)*0.15;
tax3 = 8350*0.10+(33950-8350)*0.15+(taxableIncome-33950);
tax4 = 11950*0.10+(45500-11950)*015+(taxableIncome-45500);
if (taxableIncome>=50000 && taxableIncome<=60000){
System.out.println(Math.round(taxableIncome)+" "+Math.round(tax1)+" "+Math.round(tax2)+" "+Math.round(tax3)+" "+Math.round(tax4));
}
}
return printTable(status,taxableIncome);
}
}
任何幫助將是最受歡迎的。
預先感謝您...
您將'taxableIncome'作爲參數傳入,但將其設置爲'50000'。所以它的'for'循環會自動調用,每次將'taxableIncome'重置爲'50000',從而永不結束。 – Moob