The problems this week involve compound interest While there
The problems this week involve compound interest. While there is a simple formula for determining the amount of money in an account after a given number of periods and a given interest rate, you do not need that formula (and should not use it) for these problems, as the focus of this assignment is loop structures in MATLAB. Rather, use loop structures and increase the amount in the account by a factor of 1+the interest rate each time through the loop. For example, if the annual rate is 4% and interest is paid annually, then the amount in the account is multiplied by 1.04 every time though the loop, and every pass through the loop represents one year. 1. Suppose that you deposit $10,000 in an account that pays 4% interest per year. Write a MATLAB file to calculate the account balance after a given number of years. Your program should prompt the user to input the number of years. Write the MATLAB program steps here: What is the value of the account after 10 years? __________ After 30 years?____________ 2. Change the interest rate from 4% per year to 6% per year. What is the value of the account after 10 years? __________ After 30 years?____________ 3. Consider the account from problem #1. Each year, not only does the account earn 4% interest, but the account holder also makes an annual deposit of $500 (assume before the interest is calculated for that year). Write a MATLAB file to calculate the account balance after a given number of years. Your program should prompt the user to input the number of years. Write the MATLAB program steps here:
Solution
Matlab code for 1st case:
y=input(\'Enter the Number of years to calculate compound interest\');
a=10000;%amount deposited
i=0.04;%intrest rate per year
for k=1:1:y
a=a*(1+i);
end;
final=a;
fprintf(\'the final value %f$\',final);
Matlab code for second case:
y=input(\'Enter the Number of years to calculate compound interest\');
a=10000;%amount deposited
i=0.04;%intrest rate per year
for k=1:1:y
a=a+500;
a=a*(1+i);
end;
final=a;
fprintf(\'the final value %f$\',final);
