Question

...oo Sprint LTE 5:49 PM 100% Suppose that S1000 is deposited into an account that pays 5% interest per year. at the end of each year, th amount in the account is 1.05 times the amount at the beginning of the year write a MATLAB program with a for loop to calculate the amount in the account after 10, 20, and 30 years Repeat problem 1, assuming that the interest is compounded quarterly; that is, one-fourth of the annual interest (1.25%) is added to the account every three months. Also, repeat the problem with monthly compounding For the account described in Problem 1, write a MATLAB program with a while loop to determine the number of years required for the amount in the account to reach S5,000
0 0
Add a comment Improve this question Transcribed image text
Answer #1

%matlab code

%problem 1
deposit = 1000;
interest = 0.05;
amount10 = 0;

for i=1:10
amount10 = deposit*(1+interest);
deposit = amount10;
end

fprintf('Amount after 10 years: %0.2f\n', amount10);

amount20 = amount10;
for i=10:20
amount20 = deposit*(1+interest);
deposit = amount20;
end

fprintf('Amount after 20 years: %0.2f\n', amount20);

amount30 = amount20;
for i=20:30
amount30 = deposit*(1+interest);
deposit = amount30;
end

fprintf('Amount after 30 years: %0.2f\n', amount30);
%{
output:
Amount after 10 years: 1628.89
Amount after 20 years: 2785.96
Amount after 30 years: 4764.94
%}


%problem 2
deposit = 1000;
interest = 0.25;
amount10 = 0;

% interest added 3 times a year
for i=1:10
amount10 = deposit*(1+interest);
deposit = amount10;
amount10 = deposit*(1+interest);
deposit = amount10;
amount10 = deposit*(1+interest);
deposit = amount10;
end

fprintf('Amount after 10 years: %0.2f\n', amount10);

amount20 = amount10;
for i=10:20
amount20 = deposit*(1+interest);
deposit = amount20;
amount20 = deposit*(1+interest);
deposit = amount20;
amount20 = deposit*(1+interest);
deposit = amount20;
end

fprintf('Amount after 20 years: %0.2f\n', amount20);

amount30 = amount20;
for i=20:30
amount30 = deposit*(1+interest);
deposit = amount30;
amount30 = deposit*(1+interest);
deposit = amount30;
amount30 = deposit*(1+interest);
deposit = amount30;
end

fprintf('Amount after 30 years: %0.2f\n', amount30);
%{
output:
Amount after 10 years: 807793.57
Amount after 20 years: 1274473528.91
Amount after 30 years: 2010764683385.95
%}


%probelm 3
deposit = 1000;
interest = 0.05;
year = 0;
while true
deposit = deposit*(1+interest);
year = year + 1;
if deposit >= 5000
break
end
end
fprintf('Number of years required to reach $5000: %d\n', year);
%output: Number of years required to reach $5000: 33

Add a comment
Know the answer?
Add Answer to:
Suppose that $1000 is deposited into an account that pays 5% interest per year, at the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT