-
Notifications
You must be signed in to change notification settings - Fork 0
/
quarterly_interest.m
39 lines (32 loc) · 965 Bytes
/
quarterly_interest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
% EOC Problem 4.5 A - Jeffrey Laederach
function end_balance = quarterly_interest(balance, interest)
% Example Input: "quarterly_interest(1000,5)"
% Initialize variables
balance10 = balance;
balance20 = balance;
balance30 = balance;
intrate = interest / 100;
% Quarterly interest rate
interest_rate_per_period = intrate / 4;
% Calculate compound interest for each year
for i = 1:10
for quarter = 1:4
% Calculate amount after each quarter
balance10 = balance10 * (1 + interest_rate_per_period);
end
end
% Calculate compound interest for each year
for i = 1:20
for quarter = 1:4
% Calculate amount after each quarter
balance20 = balance20 * (1 + interest_rate_per_period);
end
end
% Calculate compound interest for each year
for i = 1:30
for quarter = 1:4
% Calculate amount after each quarter
balance30 = balance30 * (1 + interest_rate_per_period);
end
end
[balance10,balance20,balance30]