-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
102 lines (97 loc) · 4.7 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css2?family=Bree+Serif&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Baloo+Bhai+2&display=swap" rel="stylesheet">
<title>Compound Interest Calculator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1 class="title center"><b>Compound Interest Calculator</b></h1>
<header>
<div class="row">
<div class="container m-auto">
<div class="dev bg-devc responsive">
<div class="card w-100 m-auto text-center responsive">
<!-- <div class="card-header bg-white text-black card title"><b>Compound Interest Calculator</b> </div> -->
<div class="card-body">
<form action="" class="form-inline w-100 center">
<div class="form-group">
<input type="text" class="form-control text-center" placeholder="p" id="p">
</div>
<div class="pl-4 pr-4"></div>
<div class="form-group">
<input type="text" class="form-control text-center" placeholder="r" id="r">
</div>
<div class="pl-4 pr-4"></div>
<div class="form-group">
<input type="text" class="form-control text-center" placeholder="n" id="n">
</div>
<div class="pl-4 pr-4"></div>
<div class="form-group">
<input type="text" class="form-control text-center" placeholder="t" id="t">
</div>
</form><br>
<div class="w-100 m-auto">
<button class="btn btn-danger w-100 responsive center" onclick="compoundInterest()">Calculate</button>
</div>
<br>
<div>
<input type="text" name="" placeholder="Total Amount" class="form-control text-center w-100 m-auto center"
id="Ans">
</div>
</div>
</div>
</div>
</div>
</div>
</header>
<p class="element center">A = final amount <br> P = initial principal balance <br> r = interest rate <br> n = number of times interest applied per time period<br> t = number of time periods elapsed</p>
</div>
</body>
<script>
// print("Compound interest Calculator")
// print("A = final amount")
// print("P = initial principal balance")
// print("r = interest rate")
// print("n = number of times interest applied per time period")
// print("t = number of time periods elapsed")
// p = int(input("Enter value of P: "))
// r = int(input("Enter value of r: "))
// t = int(input("Enter value of t: "))
// n = int(input("Enter value of n: "))
// A = p*(1+(r/n))**n*t
// print("Compound Interest: ", A)
function compoundInterest(){
let p = document.getElementById('p').value;
let r = document.getElementById('r').value;
let n = document.getElementById('n').value;
let c = document.getElementById('t').value;
const compoundInterest = (p , t, r, n) => {
let base=1+(r/(100*c))
let power=n*c;
let a=Math.pow(base, power)
document.getElementById("Ans").value=a*p
// const A = (Math.pow((1 + ( r /100*t)), (n * t)));
// const interest = A - p;
// document.getElementById('Ans').value = A*p ;
return A*p;
};
console.log(compoundInterest(p, r, n, t));
}
</script>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
-->
</html>