-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
30 lines (27 loc) · 1.13 KB
/
script.js
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
//Compute the awaited value
function compute()
{
var principal = document.getElementById("principal").value;
//Checking if principale is positive or not
if (principal <= 0)
{
//Negative or null value
document.getElementById("result").innerHTML="";
alert("Enter a positive number");
}
else
{
//Positive value
var rate = document.getElementById("rate").value;
var years = document.getElementById("years").value;
var interest = principal * years * rate /100;
var year = new Date().getFullYear()+parseInt(years);
document.getElementById("result").innerHTML="If you deposit \<span class=\"highlightTxt\"\>"+principal+"</span>,\<br\>at an interest rate of \<span class=\"highlightTxt\"\>"+rate+"%\</span\>.\<br\>You will receive an amount of \<span class=\"highlightTxt\"\>"+interest+"\</span\>,\<br\>in the year \<span class=\"highlightTxt\"\>"+year+"\</span\>\<br\>";
}
}
//Update the rate display
function updateRate()
{
var rateval = document.getElementById("rate").value+"%";
document.getElementById("rate_val").innerText=rateval;
}