Import Java.text.DecimalFormat;
/* "Program 3"
* author China Wind
* 1.3.3 example how much money to save
* Father prepared for the Little Dragon's four-year college life to save a lump sum of money,
* using the whole deposit of 0 of the way, Control dragons take 1000 yuan at the end of each month to be used next month.
* Assuming that the bank has a 0 annual coupon of 1.71% per year, figure out how much money the father needs to deposit at least.
* Problem-solving ideas:
* If the 48th month of Little Dragon University graduation, even if the band to take 1000 yuan, then first find the 47th month when the bank deposits of money at the end of the month
=1000/(1+0.0171/12);
46th month end of deposit = (The 47th month Month deposit +1000)/(1+0.0171/12)
and so on, you can find the 45th month, 44th month ... Monthly savings at the end of the
45th month deposit = (46th Month Month deposit +1000)/(1+0.0171/12)
44th month Month End deposit = (+1000)/(1+0.0171/12)
...
..... 2nd month End deposit = (3rd month Month deposit +1000)/(1+0.0171/12)
1th month month End deposit = (+1000)/(1+0.0171/12)/public
class T003 { Public
static void Main (string[] args) {
int fetch = 1000; Monthly amount of money;
double rate = 0.0171f; Interest rate
Double corpus[] = new double[49]; Recordset
DecimalFormat df = new DecimalFormat ("#0.");
CORPUS[48] = (double) fetch;
for (int i=47;i>0;i--) {
corpus[i] = (corpus[i+1]+fetch)/(1+RATE/12);
}
for (int i=48;i>0;i--) {
System.out.println ("+i+" month Whippany total: "+df.format (Corpus[i])");}}
Run Result:
。 。 。