-
-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #935 from AsmitaMishra24/main
Added RD Calculator
- Loading branch information
Showing
2 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
document.addEventListener("DOMContentLoaded", function() { | ||
document.getElementById("calculate-Btn3").addEventListener("click", function() { | ||
const monthlyInstallment = parseFloat(document.getElementById("monthly-installment").value); | ||
const annualInterestRate = parseFloat(document.getElementById("rate1").value); | ||
const timePeriodMonths = parseFloat(document.getElementById("months1").value); | ||
|
||
if (isNaN(monthlyInstallment) || isNaN(annualInterestRate) || isNaN(timePeriodMonths)) { | ||
alert("Please fill in all fields"); | ||
return; | ||
} | ||
|
||
const monthlyInterestRate = annualInterestRate / 12 / 100; | ||
|
||
let maturityAmount = 0; | ||
for (let i = 0; i < timePeriodMonths; i++) { | ||
maturityAmount += monthlyInstallment * Math.pow((1 + monthlyInterestRate), (timePeriodMonths - i)); | ||
} | ||
|
||
const totalInvestAmount = monthlyInstallment * timePeriodMonths; | ||
const interestEarned = maturityAmount - totalInvestAmount; | ||
|
||
document.getElementById("interestEarned1").innerText = `₹${interestEarned.toFixed(2)}`; | ||
document.getElementById("maturityAmount1").innerText = `₹${maturityAmount.toFixed(2)}`; | ||
}); | ||
|
||
document.getElementById("clearBtn2").addEventListener("click", function() { | ||
document.getElementById("monthly-installment").value = ''; | ||
document.getElementById("rate1").value = ''; | ||
document.getElementById("months1").value = ''; | ||
document.getElementById("interestEarned1").innerText = ''; | ||
document.getElementById("maturityAmount1").innerText = ''; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters