現在,很多人都有個人住房貸款,或者將要有個人住房貸款。那麼,就讓我們用 C# 寫一個計算器,用於計算個人住房貸款的還款計劃表。
這個計算器能夠根據你給出的貸款金額、貸款期數、貸款日期、還款方式、貸款種類,計算出相應的還款計劃表,如上圖所示。
這樣,就很容易知道每月要還多少錢,到現在為止剩余多少貸款未還,最終要付出多少貸款利息,等等。
貸款利率是由貸款種類決定的,存放在 LoanCalculator.XML 文件中:
<?XML version="1.0" encoding="utf-8" ?>
<LoanCalculator>
<option balance="13.8" months="180" date="2004-07-23" method="等本息" item="公積金" />
<items>
<item title="公積金">
<rate date="1001-01-01" low="3.6" high="4.05" />
<rate date="2005-01-01" low="3.78" high="4.23" />
<rate date="2006-01-01" low="3.96" high="4.41" />
<rate date="2007-01-01" low="4.14" high="4.59" />
<rate date="2008-01-01" low="5.04" high="5.22" />
<rate date="2009-01-01" low="3.33" high="3.87" />
</item>
<item title="商業性基准">
<rate date="1001-01-01" low="5.51" high="5.75" />
<rate date="2007-01-01" low="5.51" high="5.81" />
<rate date="2008-01-01" low="6.579" high="6.65" />
<rate date="2009-01-01" low="5.76" high="5.94" />
</item>
<item title="商業性優惠">
<rate date="1001-01-01" low="5.51" high="5.75" />
<rate date="2007-01-01" low="5.51" high="5.81" />
<rate date="2008-01-01" low="6.579" high="6.65" />
<rate date="2009-01-01" low="4.03" high="4.16" />
</item>
</items>
< /LoanCalculator>