Skip to content

Commit 0a26c62

Browse files
committed
made the working laon calculator
1 parent 4ad3011 commit 0a26c62

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"liveServer.settings.port": 5502
2+
"liveServer.settings.port": 5502,
3+
"githubPullRequests.ignoredPullRequestBranches": [
4+
"main"
5+
]
36
}

projects/loan-calculator/index.html

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,26 @@
77
<title>Loan Calculatortitle>
88
<link rel="stylesheet" href="style.css">
99
head>
10-
<body>
10+
<body style="font-family: 'Times New Roman', Times, serif;">
11+
<form action="" id="from">
1112
<div class="container">
1213
<h1>Loan Calculatorh1>
1314
<p>Loan Amount $
14-
<input onchange="calculateLoan()" class="input" type="number" id="loan-amount" min="1" max="500000" value="10000">
15+
<input class="input" type="number" id="loan-amount" min="1" max="500000" value="10000">
1516
p>
1617
<p>Interest Rate %
17-
<input onchange="calculateLoan()" class="input" type="number" id="interest-rate" min="0" max="100" value="10" step=".1">
18+
<input class="input" type="number" id="interest-rate" min="0" max="100" value="10" step=".1">
1819
p>
1920
<p>Months to pay
20-
<input onchange="calculateLoan()" class="input" type="number" id="months-to-pay" min="6" max="48" value="12">
21+
<input class="input" type="number" id="months-to-pay" min="6" max="48" value="12">
2122
p>
22-
<p class="payment" id="payment">Monthly Payment:p>
23+
<button id="c" class="Cen" onclick="calculateLoan()" style="font-size: 15px; border-radius: 5px;height: 30px;text-align: center;">Calculatebutton>
24+
<br>
25+
<br>
26+
27+
<div id="payment">div>
2328
div>
29+
form>
2430

2531
<script src="index.js">script>
2632
body>

projects/loan-calculator/index.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
function calculateLoan() {
2-
loanAmountValue = document.getElementById("loan-amount").value;
2+
event.preventDefault();
33

4-
interestRateValue = document.getElementById("interest-rate").value;
4+
var loanAmountValue = document.getElementById("loan-amount").value;
55

6-
MonthsToPayValue = document.getElementById("months-to-pay").value;
6+
var interestRateValue = document.getElementById("interest-rate").value;
77

8-
interest = (loanAmountValue * (interestRateValue * 0.01)) / MonthsToPayValue;
8+
var MonthsToPayValue = document.getElementById("months-to-pay").value;
9+
10+
var interest = (loanAmountValue * (interestRateValue * 0.01)) / MonthsToPayValue;
911

1012
monthlyPayment = (loanAmountValue / MonthsToPayValue + interest).toFixed(2);
1113

12-
document.getElementById(
13-
"payment"
14-
).innerHTML = `Monthly Payment: ${monthlyPayment}`;
14+
15+
document.getElementById("payment").innerHTML="Total Loan to be paid is Ruppees " + monthlyPayment
16+
document.getElementById("loan-amount").value = "";
17+
document.getElementById("interest-rate").value = "";
18+
document.getElementById("months-to-pay").value = "";
19+
20+
1521
}

projects/loan-calculator/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ body{
66
justify-content: center;
77
align-items: center;
88
font-family: 'Courier New', Courier, monospace;
9+
background-color: rgb(246, 150, 82);
910
}
1011

1112
.container{
@@ -24,4 +25,10 @@ body{
2425
.payment{
2526
font-weight: 600;
2627
font-size: 20px;
28+
}
29+
.Cen{
30+
text-align: center;
31+
justify-content: center;
32+
align-items: center;
33+
margin-left: 80px;
2734
}

0 commit comments

Comments
 (0)