function calculateSolarSize() { // Capture user input const electricBill = parseFloat(document.getElementById(“electricBill”).value); if (isNaN(electricBill) || electricBill <= 0) { alert("Please enter a valid electric bill."); return; } // Dynamic variables const localRate = 0.18; // Using an average of $0.17-$0.19 for better precision const solarIrradiance = 5.5; // Adjusted for regional variability (avg daily sunlight) const panelEfficiency = 0.28; // Adjusted for real-world panel output efficiency (kW per panel per sunlight hour) // Monthly energy consumption from electric bill (in kWh) const monthlyConsumption = electricBill / localRate; // Monthly panel production (in kWh) const monthlyProductionPerPanel = solarIrradiance * panelEfficiency * 30; // System size required to offset consumption (in kW) const requiredSystemSizeKW = monthlyConsumption / monthlyProductionPerPanel; // Results display document.getElementById("estimatedSize").innerText = `Estimated System Size: ${requiredSystemSizeKW.toFixed(2)} kW`; // Ensure the results are visible document.getElementById("result").style.display = "block"; // Debug logs for transparency console.log("Electric Bill: $", electricBill); console.log("Local Rate: $", localRate); console.log("Monthly Consumption (kWh):", monthlyConsumption); console.log("Monthly Production per Panel (kWh):", monthlyProductionPerPanel); console.log("Required System Size (kW):", requiredSystemSizeKW); }