forked from eblinick/SimpleInterestCalculator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
30 lines (27 loc) · 904 Bytes
/
script.js
File metadata and controls
30 lines (27 loc) · 904 Bytes
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
function compute()
{
var t = document.getElementById("principal").value;
var p = Number(t)
if (p<=0) {
alert("Please enter positive Principal");
principal.focus();
return false;
}
var r = document.getElementById("rate").value / 10;
if (r==0) {
r = 10;
}
var y = document.getElementById("years").value;
if (y==0) { y = 1;}
var d = new Date();
var fut = Number(d.getFullYear());
fut += Number(y)
rslt = (p * y * r / 100);
ans = '<p>If you deposit <span class="yel">' + p + '</span></p>'
ans += '<p>an interest rate of <span class="yel">' + r + '%. </span></p>';
ans = ans + '<p>You will receive an amount of <span class="yel">' + rslt + ',</span> </p>';
ans = ans + '<p>in the year <span class="yel">' + fut + '</span></p>'
document.getElementById("result").innerHTML = ans;
//alert(rslt)
return ans;
}