Share Certificate Calculator

function calculateShareCertificate() { var initialDeposit = parseFloat(document.getElementById("initialDeposit").value); var annualRate = parseFloat(document.getElementById("annualRate").value); var termLength = parseFloat(document.getElementById("termLength").value); var compoundingFrequency = parseInt(document.getElementById("compoundingFrequency").value); var resultDiv = document.getElementById("result"); if (isNaN(initialDeposit) || initialDeposit <= 0) { resultDiv.innerHTML = "Please enter a valid initial deposit amount."; return; } if (isNaN(annualRate) || annualRate < 0) { resultDiv.innerHTML = "Please enter a valid annual interest rate."; return; } if (isNaN(termLength) || termLength <= 0) { resultDiv.innerHTML = "Please enter a valid term length in years."; return; } var rateDecimal = annualRate / 100; var totalCompounds = compoundingFrequency * termLength; var maturityValue = initialDeposit * Math.pow((1 + (rateDecimal / compoundingFrequency)), totalCompounds); var totalInterestEarned = maturityValue – initialDeposit; resultDiv.innerHTML = "Initial Deposit: $" + initialDeposit.toFixed(2) + "" + "Total Interest Earned: $" + totalInterestEarned.toFixed(2) + "" + "Maturity Value: $" + maturityValue.toFixed(2) + ""; } .share-certificate-calculator-container { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f9f9f9; padding: 25px; border-radius: 10px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); max-width: 600px; margin: 20px auto; border: 1px solid #e0e0e0; } .share-certificate-calculator-container h2 { color: #2c3e50; text-align: center; margin-bottom: 20px; font-size: 1.8em; } .share-certificate-calculator-container p { color: #34495e; line-height: 1.6; margin-bottom: 15px; } .calculator-form label { display: block; margin-bottom: 8px; color: #34495e; font-weight: bold; } .calculator-form input[type="number"], .calculator-form select { width: calc(100% – 22px); padding: 12px; margin-bottom: 15px; border: 1px solid #ccc; border-radius: 5px; font-size: 1em; box-sizing: border-box; } .calculator-form button { background-color: #28a745; color: white; padding: 12px 25px; border: none; border-radius: 5px; cursor: pointer; font-size: 1.1em; display: block; width: 100%; transition: background-color 0.3s ease; } .calculator-form button:hover { background-color: #218838; } .calculator-results { background-color: #e9f7ef; border: 1px solid #d4edda; border-radius: 8px; padding: 20px; margin-top: 25px; } .calculator-results h3 { color: #2c3e50; margin-top: 0; margin-bottom: 15px; font-size: 1.4em; text-align: center; } .calculator-results p { font-size: 1.1em; color: #218838; margin-bottom: 10px; } .calculator-results p strong { color: #2c3e50; }

Leave a Comment