Certificate of Deposit (CD) Rate Calculator
Understanding how different Certificate of Deposit (CD) rates can impact your potential earnings is crucial for making informed investment decisions. A CD is a savings product that offers a fixed interest rate for a specified term. By using this calculator, you can easily compare the potential returns from various CD offerings without any financial jargon.
Calculate Earnings
function calculateCertificateRates() {
var initialDeposit = parseFloat(document.getElementById("initialDeposit").value);
var annualPercentageRate = parseFloat(document.getElementById("annualPercentageRate").value);
var termInYears = parseFloat(document.getElementById("termInYears").value);
var compoundingFrequency = parseInt(document.getElementById("compoundingFrequency").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(initialDeposit) || isNaN(annualPercentageRate) || isNaN(termInYears) || isNaN(compoundingFrequency)) {
resultDiv.innerHTML = "Please enter valid numbers for all fields.";
return;
}
if (initialDeposit <= 0 || annualPercentageRate < 0 || termInYears <= 0 || compoundingFrequency <= 0) {
resultDiv.innerHTML = "Please enter positive values for deposit, APR, term, and a valid compounding frequency.";
return;
}
var ratePerPeriod = (annualPercentageRate / 100) / compoundingFrequency;
var numberOfPeriods = termInYears * compoundingFrequency;
var futureValue = initialDeposit * Math.pow(1 + ratePerPeriod, numberOfPeriods);
var totalInterestEarned = futureValue – initialDeposit;
resultDiv.innerHTML =
"
Estimated Total Earnings: $" + futureValue.toFixed(2) + "" +
"
Total Interest Earned: $" + totalInterestEarned.toFixed(2) + "";
}
.calculator-container {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 500px;
margin: 20px auto;
background-color: #f9f9f9;
}
.calculator-inputs {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 15px;
margin-bottom: 20px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
}
.input-group input[type="number"],
.input-group select {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1em;
}
button {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1em;
width: 100%;
margin-bottom: 20px;
}
button:hover {
background-color: #45a049;
}
.calculator-result {
border-top: 1px solid #eee;
padding-top: 15px;
text-align: center;
font-size: 1.1em;
}
.calculator-result p {
margin: 5px 0;
}