Understanding Certificates of Deposit (CDs) and their potential returns is crucial for smart investing. A 2-month CD is a type of savings account that holds your money for a fixed period (in this case, two months) at a fixed interest rate. In exchange for committing your funds, the bank typically offers a higher Annual Percentage Yield (APY) than a standard savings account. This calculator helps you estimate the earnings from a 2-month CD based on the principal amount and the advertised APY.
function calculateCdEarnings() {
var principal = parseFloat(document.getElementById("principal").value);
var apy = parseFloat(document.getElementById("apy").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(principal) || isNaN(apy) || principal < 0 || apy < 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for Principal and APY.";
return;
}
// CD term is 2 months. APY is an annual rate.
// We need to convert the annual APY to a rate for 2 months.
// (1 + APY)^(time_in_years) – 1 = total_return
// For 2 months, time_in_years = 2/12
// So, the rate for 2 months is (1 + APY)^(2/12) – 1
var annualRate = apy / 100; // Convert APY percentage to decimal
var timeInYears = 2 / 12;
var monthlyEquivalentRate = Math.pow(1 + annualRate, timeInYears) – 1;
var earnings = principal * monthlyEquivalentRate;
var totalValue = principal + earnings;
resultDiv.innerHTML = "