"Program 3" How much money to deposit (reverse instance) __java algorithm

Source: Internet
Author: User
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: 。 。 。

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.