-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculate-component-interest.html
More file actions
58 lines (46 loc) · 1.58 KB
/
Copy pathcalculate-component-interest.html
File metadata and controls
58 lines (46 loc) · 1.58 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!--
Developed BY : Elmira Amanollahi;
Date: 14/12/2016;
Consider the following problem statement:
A person invests $1000.00 in a savings account
yielding 5 percent interest. Assuming that all
interest is left on deposit in the account,
calculate and print the amount of money in the
account at the end of each year for 10 years.
Use the following formula for determining
these amounts:
a = p (1 + r)^n
Where
p is the original amount invested (i.e., the principal)
r is the annual rate,
n is the number of years, and
a is the amount on deposit at the end of the nth year
This problem involves a loop that performs the
indicated calculation for each of the 10 years
the money remains on deposit
-->
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Calculate Component Interest</title>
<script type="text/javascript">
//1.Declaration
var invest = 1000;
var annualRate = 5/100;
function deposit(invest, annualRate, yearNum) {
//a = p (1 + r)^n
return invest*(Math.pow((1 + annualRate), yearNum));
}
// window.alert("hi");
//document.writeln("hey");
//var amountInvested = deposit(1000,5,10);
for (var i = 1; i <= 10; i++) {
invest = deposit(invest,annualRate,i);
document.writeln(invest+"<br/>");
}
</script>
</head>
<body>
</body>
</html>