Skip to content

Commit 2cc9f23

Browse files
committed
added loan calculator
1 parent 6fb82f3 commit 2cc9f23

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

Loan Calculator/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link rel="stylesheet" href="style.css">
8+
<title>Loan Calculator</title>
9+
</head>
10+
<body>
11+
<div class="container">
12+
<h3>Loan Calculator</h3>
13+
<p>Loan Amount: <input type="number" value="1" id="amount" min="0" onchange="calculateLoan()"></p>
14+
<p>Interest Rate: <input type="number" value="0.1" id="interest" min="0" onchange="calculateLoan()"> % </p>
15+
<p>Months to Pay: <input type="number" value="1" id="months" min="0" onchange="calculateLoan()"> </p>
16+
17+
<h2 id="payment"></h2>
18+
</div>
19+
<script src="script.js"></script>
20+
</body>
21+
</html>

Loan Calculator/script.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
function calculateLoan(){
3+
const amount = document.querySelector("#amount").value;
4+
const interestRate = document.querySelector("#interest").value;
5+
const months = document.querySelector("#months").value;
6+
7+
const interest =(amount*(interestRate*0.01))/months;
8+
const payment = ((amount/months) + interest).toFixed(2);
9+
10+
document.querySelector("#payment").innerHTML = `EMI: ₹ ${payment}`
11+
12+
}

Loan Calculator/style.css

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
body{
2+
background-color: pink;
3+
}
4+
5+
.container{
6+
width: 400px;
7+
height: 450px;
8+
background-color: #ff1d58;
9+
position: absolute;
10+
top: 50%;
11+
left: 50%;
12+
transform: translateX(-50%) translateY(-50%);
13+
color: white;
14+
padding: 20px 0 0 100px;
15+
border-radius: 50px;
16+
}
17+
18+
h3{
19+
font-size: 35px;
20+
}
21+
22+
input{
23+
width: 80%;
24+
padding: 8px;
25+
border: none;
26+
margin-top: 10px;
27+
}
28+
29+
input:focus{
30+
outline: none;
31+
}
32+
33+
h2{
34+
margin-top: 30px;
35+
}
36+
37+
@media screen and (max-width:360px){
38+
.container{
39+
border-radius: 0;
40+
top: 37%;
41+
}
42+
}

0 commit comments

Comments
 (0)