How to save money and maximize profits
Assume that the monthly interest rates of the entire bank deposit for different periods are:
0.63% term = 1 year
0.66% term = 2 years
0.69% term = 3 years
0.75% term = 5 years
0.84% term = 8 years
Interest = Principal * monthly interest rate * 12 * deposit period.
Now someone has 2000 yuan in his hand. Please select a deposit scheme through computation, this gives the bank the most interest after 20 years of deposit (assuming that the bank does not pay any interest for the period beyond the deposit term ).
* Problem analysis and Algorithm
In order to get the most interest, the money deposited in the bank should be obtained immediately upon expiration, and then the original principal and interest should be immediately added up and then saved to the bank as the new principal, this keeps rolling until the last 20 years. Due to the different deposit interest rates, different deposit methods (years) save 20 years to get different interest.
For analysis purposes, 2000 RMB is saved for 20 years, including I1 for 1 year, I2 for 2 years, I3 for 3 years, I5 for 5 years, and i8 for 8 years, the total sum of profits The depositor shall receive upon expiration is:
2000*(1 + rate1) i1 * (1 + rate2) I2 * (1 + rate3) I3 * (1 + rate5) I5 * (1 + rate8) i8
Raten indicates the interest rate corresponding to the deposit period. You can also obtain the following restrictions based on the question:
0 <= i8 <= 2
0 <= I5 <= (20-8 * i8)/5
0 <= I3 <= (20-8 * i8-5 * I5)/3
0 <= I2 <= (20-8 * i8-5 * i5-3 * I3)/2
0 <= I1 = 20-8 * i8-5 * i5-3 * i3-2 * I2
You can use the exhaustive method to enumerate all the combinations of i8, I5, I3, I2, and I1, and then use the formula used to calculate the maximum value, which is the best deposit scheme.
* Program Program comments
# Include <stdio. h>
# Include <math. h>
Void main ()
{
Int i8, I5, I3, I2, i1, n8, N5, N3, N2, N1;
Float max = 0, term;
For (i8 = 0; i8 <3; i8 ++)/* provides all possible deposit methods */
For (I5 = 0; I5 <= (20-8 * i8)/5; I5 ++)
For (I3 = 0; I3 <= (20-8 * i8-5 * I5)/3; I3 ++)
For (I2 = 0; I2 <= (20-8 * i8-5 * I3)/2; I2 ++)
{
I1 = 20-8 * i8-5 * i5-3 * i3-2 * I2;
Term = 2000.0 * POW (double) (1 + 0.0063*12), (double) i1)
* POW (double) (1 + 2*0.0063*12), (double) I2)
* POW (double) (1 + 3*0.0069*12), (double) I3)
* POW (double) (1 + 5*0.0075*12), (double) I5)
* POW (double) (1 + 8*0.0084*12), (double) i8 );
/* Calculate the total sum of profits upon expiration */
If (term> MAX)
{
Max = term; n1 = I1; N2 = I2; N3 = I3; N5 = I5; n8 = i8;
}
}
Printf ("For maxinum profit, He shoshould so save his money in a bank: N ");
Printf ("made fixed deposit for 8 year: % d timesn", n8 );
Printf ("made fixed deposit for 5 year: % d timesn", N5 );
Printf ("made fixed deposit for 3 year: % d timesn", N3 );
Printf ("made fixed deposit for 2 year: % d timesn", N2 );
Printf ("made fixed deposit for 1 year: % d timesn", N1 );
Printf ("Toal: %. 2fn", max );
/* Output deposit Method */
}
* Running result
For maxinum profit, He shoshould so save his money in a bank:
Made fixed deposit for 8 year: 0 times
Made fixed deposit for 5 year: 4 times
Made fixed deposit for 3 year: 0 times
Made fixed deposit for 2 year: 0 times
Made fixed deposit for 1 year: 0 times
Total: 8841.01
It can be seen that the best deposit scheme is to deposit for five years for four consecutive times.
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.