Apartment Turnover Rate Calculator
function calculateTurnoverRate() {
var totalUnits = parseFloat(document.getElementById("totalUnits").value);
var unitsVacated = parseFloat(document.getElementById("unitsVacated").value);
var periodInMonths = parseFloat(document.getElementById("periodInMonths").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(totalUnits) || isNaN(unitsVacated) || isNaN(periodInMonths)) {
resultDiv.innerHTML = "Please enter valid numbers for all fields.";
return;
}
if (totalUnits <= 0) {
resultDiv.innerHTML = "Total number of units must be greater than zero.";
return;
}
if (unitsVacated < 0) {
resultDiv.innerHTML = "Number of units vacated cannot be negative.";
return;
}
if (periodInMonths totalUnits) {
resultDiv.innerHTML = "Number of units vacated cannot exceed the total number of units.";
return;
}
// Formula: Turnover Rate = (Number of Units Vacated / Total Number of Units) * 100
var turnoverRate = (unitsVacated / totalUnits) * 100;
// To annualize if the period is not 12 months, we can adjust the number of vacated units conceptually.
// However, the standard calculation is often based on the actual units vacated within the given period.
// If we want to represent an *annualized* rate based on a shorter period, we'd do:
// var annualizedTurnoverRate = turnoverRate * (12 / periodInMonths);
// But for simplicity and direct interpretation of the provided period, we'll stick to the rate for the given period.
var formattedTurnoverRate = turnoverRate.toFixed(2);
resultDiv.innerHTML = "