This calculator helps you estimate the earnings from a Certificate of Deposit (CD) with a US bank. CDs are a type of savings account with a fixed term and a fixed interest rate, offering a predictable way to grow your money. You deposit a sum of money for a set period, and in return, the bank pays you a specific interest rate.
Annually
Semi-annually
Quarterly
Monthly
Daily
function calculateCDInterest() {
var principal = parseFloat(document.getElementById("principalAmount").value);
var rate = parseFloat(document.getElementById("annualInterestRate").value);
var termMonths = parseInt(document.getElementById("termInMonths").value);
var compoundingFrequency = parseInt(document.getElementById("compoundingFrequency").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(principal) || isNaN(rate) || isNaN(termMonths) || isNaN(compoundingFrequency)) {
resultDiv.innerHTML = "Please enter valid numbers for all fields.";
return;
}
if (principal <= 0 || rate < 0 || termMonths <= 0 || compoundingFrequency <= 0) {
resultDiv.innerHTML = "Please enter positive values for deposit amount, term, and compounding frequency, and a non-negative rate.";
return;
}
var ratePerPeriod = rate / 100 / compoundingFrequency;
var numberOfPeriods = termMonths / 12 * compoundingFrequency;
// Compound interest formula: A = P (1 + r/n)^(nt)
// Here, A = final amount, P = principal, r = annual rate, n = compounding frequency per year, t = term in years
// We've adjusted to use numberOfPeriods and ratePerPeriod directly
var totalAmount = principal * Math.pow(1 + ratePerPeriod, numberOfPeriods);
var interestEarned = totalAmount – principal;
resultDiv.innerHTML = `
Estimated Earnings: $${interestEarned.toFixed(2)}
Total Value at Maturity: $${totalAmount.toFixed(2)}
`;
}
#cdRateCalculator {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 500px;
margin: 20px auto;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
#cdRateCalculator h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.calculator-inputs {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 15px;
margin-bottom: 20px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
.input-group input, .input-group select {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1rem;
}
#cdRateCalculator button {
display: block;
width: 100%;
padding: 12px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 1.1rem;
cursor: pointer;
transition: background-color 0.3s ease;
}
#cdRateCalculator button:hover {
background-color: #0056b3;
}
.calculator-result {
margin-top: 20px;
padding: 15px;
background-color: #e9ecef;
border-radius: 4px;
text-align: center;
font-size: 1.1rem;
color: #333;
}
.calculator-result p {
margin: 5px 0;
}