Growth Rate Calculator
This calculator helps you determine the growth rate of a value over a specific period. Growth rate is a fundamental concept used in finance, economics, and many other fields to understand how a quantity has changed over time. It's often expressed as a percentage per period (e.g., per year).
function calculateGrowthRate() {
var initialValue = parseFloat(document.getElementById("initialValue").value);
var finalValue = parseFloat(document.getElementById("finalValue").value);
var periods = parseInt(document.getElementById("periods").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(initialValue) || isNaN(finalValue) || isNaN(periods) || initialValue <= 0 || periods <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for all fields.";
return;
}
// Formula for compound annual growth rate (CAGR)
// CAGR = (Final Value / Initial Value)^(1 / Number of Periods) – 1
var growthRate = Math.pow((finalValue / initialValue), (1 / periods)) – 1;
// Convert to percentage
var growthRatePercentage = growthRate * 100;
resultDiv.innerHTML = "The Growth Rate is:
" + growthRatePercentage.toFixed(2) + "% per period.";
}
.calculator-container {
font-family: Arial, sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 500px;
margin: 20px auto;
background-color: #f9f9f9;
}
.calculator-container h2 {
text-align: center;
color: #333;
margin-bottom: 15px;
}
.calculator-inputs {
display: flex;
flex-direction: column;
gap: 15px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
.input-group input[type="number"] {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1rem;
}
.calculator-inputs button {
padding: 12px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
transition: background-color 0.3s ease;
}
.calculator-inputs button:hover {
background-color: #0056b3;
}
.calculator-result {
margin-top: 20px;
padding: 15px;
background-color: #e9ecef;
border: 1px solid #ced4da;
border-radius: 4px;
text-align: center;
}
.calculator-result p {
font-size: 1.1rem;
color: #333;
}
.calculator-result strong {
color: #28a745;
}