From 4832980ca31d070bc1fe1f0b791f6a47eb2b2182 Mon Sep 17 00:00:00 2001 From: AsmitaMishra24 <146121869+AsmitaMishra24@users.noreply.github.com> Date: Fri, 9 Aug 2024 16:00:30 +0530 Subject: [PATCH] Added FD Calculator --- tools/FDCalculator.js | 27 ++++++++++++++++++++ tools/sip.html | 59 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 tools/FDCalculator.js diff --git a/tools/FDCalculator.js b/tools/FDCalculator.js new file mode 100644 index 0000000..800a786 --- /dev/null +++ b/tools/FDCalculator.js @@ -0,0 +1,27 @@ +document.addEventListener('DOMContentLoaded', function() { + document.getElementById('calculateBtn2').addEventListener('click', function() { + let principal = parseFloat(document.getElementById('principal').value); + let rate = parseFloat(document.getElementById('rate').value); + let years = parseInt(document.getElementById('years1').value); + + + if (isNaN(principal) || isNaN(rate) || isNaN(years) || principal <= 0 || rate <= 0 || years <= 0) { + alert('Please enter valid values.'); + return; + } + + let maturityAmount = principal * Math.pow((1 + rate / 100), years); + let interestEarned = maturityAmount - principal; + + document.getElementById('interestEarned').textContent = '₹' + interestEarned.toFixed(2); + document.getElementById('maturityAmount').textContent = '₹' + maturityAmount.toFixed(2); + }); + + document.getElementById('clearBtn1').addEventListener('click', function() { + document.getElementById('principal').value = ''; + document.getElementById('rate').value = ''; + document.getElementById('years1').value = ''; + document.getElementById('interestEarned').textContent = ''; + document.getElementById('maturityAmount').textContent = ''; + }); +}); diff --git a/tools/sip.html b/tools/sip.html index 2784dda..de3cfa7 100644 --- a/tools/sip.html +++ b/tools/sip.html @@ -1001,6 +1001,7 @@
The FD(Fixed Deposit) Calculator helps compute the maturity amount and interest earned on fixed deposits based on the principal, interest rate, and duration.
+Total Interest Earned:
+Total Maturity Amount:
+