-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
42 lines (41 loc) · 1.83 KB
/
index.html
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
<head>
<meta charset="utf-8">
<title>Mayur3636</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div class="wrapper">
<h1>SIP CALCULATOR</h1>
<div class="field">
<label for="">INVESTMENT AMOUNT ₹</label>
<div><input type="text" class="amount" placeholder="10000₹"></div>
</div>
<div class="field">
<label for="">Return Rate %</label>
<div><input type="text" class="rate" placeholder="15%"></div>
</div>
<div class="field">
<label for="">Duration Yrs</label>
<div><input type="text" class="time" placeholder="20Yrs"></div>
</div>
<button onclick="calculateSIP()">CALCULATE</button>
<h5>AMOUNT INVESTED: <p id="aInvested"></p></h5>
<h5>FINAL AMOUNT: <p id="finalAmount"></p></h5>
</div>
<script>
var amount = document.querySelector(".amount");
var rate = document.querySelector(".rate");
var time = document.querySelector(".time");
function calculateSIP(){
var monthlyRate = rate.value / 12 / 100;
var months = time.value * 12;
var futureValue = 0;
futureValue = amount.value * (Math.pow(1 + monthlyRate, months) - 1) /monthlyRate;
var amountInvested = amount.value*months;
console.log(futureValue, amountInvested);
document.getElementById("aInvested").innerHTML ="₹"+ amountInvested;
document.getElementById("finalAmount").innerHTML ="₹"+ Math.round(futureValue > 0 ? futureValue: 0);
}
</script>
</body>
</html>