Private School vs. Public School Cost Analyzer

Private School Annual Costs

One-Time Fees

Public School Annual Costs

One-Time Fees

Comparison Summary

Please fill in the details on the 'Private School Costs' and 'Public School Costs' tabs. The summary will be calculated here.

Number of years must be a positive number.

"; pscDownloadPdfButtonElem.style.display = 'none'; return null; } let privateAnnualCost = 0; pscPrivateInputIds.forEach(id => privateAnnualCost += pscGetNumValue(id)); const privateOneTime = pscGetNumValue('pscPrivateOneTimeFees'); const privateTotalPeriodCost = (privateAnnualCost * years) + privateOneTime; let publicAnnualCost = 0; pscPublicInputIds.forEach(id => publicAnnualCost += pscGetNumValue(id)); const publicOneTime = pscGetNumValue('pscPublicOneTimeFees'); const publicTotalPeriodCost = (publicAnnualCost * years) + publicOneTime; const differenceTotal = privateTotalPeriodCost - publicTotalPeriodCost; return { years, privateAnnual: privateAnnualCost, privateOneTime, privateTotal: privateTotalPeriodCost, publicAnnual: publicAnnualCost, publicOneTime, publicTotal: publicTotalPeriodCost, difference: differenceTotal, childName: pscChildNameElem.value || "Your Child" }; } function pscCalculateAndDisplay() { if (!pscComparisonOutputDiv || !pscDownloadPdfButtonElem) { console.error("PSC: Summary output elements not found."); return; } const results = pscCalculateCosts(); if (!results) return; let diffText, diffClass; if (results.difference > 0) { diffText = `${pscFormatCurrency(results.difference)} more for Private School`; diffClass = 'psc-difference-positive'; // Red for private more expensive } else if (results.difference < 0) { diffText = `${pscFormatCurrency(Math.abs(results.difference))} more for Public School`; diffClass = 'psc-difference-negative'; // Green for public more expensive } else { diffText = "Costs are equal"; diffClass = ''; } const childNameDisplay = results.childName === "Your Child" ? "for your child" : `for ${results.childName}`; pscComparisonOutputDiv.innerHTML = `

Cost Summary ${childNameDisplay} (Over ${results.years} Year${results.years === 1 ? '' : 's'})

Private School
Estimated Annual Cost:${pscFormatCurrency(results.privateAnnual)}
One-Time Fees:${pscFormatCurrency(results.privateOneTime)}
Total Estimated Cost Over ${results.years} Year${results.years === 1 ? '' : 's'}:${pscFormatCurrency(results.privateTotal)}
Public School
Estimated Annual Cost:${pscFormatCurrency(results.publicAnnual)}
One-Time Fees:${pscFormatCurrency(results.publicOneTime)}
Total Estimated Cost Over ${results.years} Year${results.years === 1 ? '' : 's'}:${pscFormatCurrency(results.publicTotal)}
Overall Difference
Difference in Total Cost (Private - Public):${diffText}
`; pscDownloadPdfButtonElem.style.display = 'inline-block'; } async function pscDownloadPDF() { const { jsPDF } = window.jspdf; if (typeof html2canvas === 'undefined' || typeof jsPDF === 'undefined') { alert('Error: PDF generation libraries not loaded.'); return; } const results = pscCalculateCosts(); if (!results) { alert("Cannot generate PDF: please calculate valid results first."); return; } const pdfContentWrapper = document.createElement('div'); pdfContentWrapper.className = 'psc-pdf-content-wrapper'; let diffTextPDF, diffClassPDF; if (results.difference > 0) diffTextPDF = `${pscFormatCurrency(results.difference)} more for Private School`; else if (results.difference < 0) diffTextPDF = `${pscFormatCurrency(Math.abs(results.difference))} more for Public School`; else diffTextPDF = "Costs are equal"; const childNameDisplayPDF = results.childName === "Your Child" ? "Your Child" : results.childName; let privateInputsHTML = '
Private School Annual Inputs:
'; pscPrivateInputIds.forEach(id => { const label = document.querySelector(`label[for='${id}']`).childNodes[0].textContent.trim(); privateInputsHTML += `

${label} ${pscFormatCurrency(pscGetNumValue(id))}

`; }); privateInputsHTML += `

One-Time Fees: ${pscFormatCurrency(results.privateOneTime)}

`; let publicInputsHTML = '
Public School Annual Inputs:
'; pscPublicInputIds.forEach(id => { const label = document.querySelector(`label[for='${id}']`).childNodes[0].textContent.trim(); publicInputsHTML += `

${label} ${pscFormatCurrency(pscGetNumValue(id))}

`; }); publicInputsHTML += `

One-Time Fees: ${pscFormatCurrency(results.publicOneTime)}

`; pdfContentWrapper.innerHTML = `

School Cost Comparison for ${childNameDisplayPDF}

Analysis Period: ${results.years} Year${results.years === 1 ? '' : 's'}

DescriptionPrivate SchoolPublic School
Estimated Annual Recurring Cost${pscFormatCurrency(results.privateAnnual)}${pscFormatCurrency(results.publicAnnual)}
Total One-Time Fees${pscFormatCurrency(results.privateOneTime)}${pscFormatCurrency(results.publicOneTime)}
Total Estimated Cost Over Period${pscFormatCurrency(results.privateTotal)}${pscFormatCurrency(results.publicTotal)}
Difference (Private - Public)${diffTextPDF}
${privateInputsHTML} ${publicInputsHTML}

Report generated on: ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}

`; document.body.appendChild(pdfContentWrapper); try { const canvas = await html2canvas(pdfContentWrapper, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgProps = pdf.getImageProperties(imgData); const ratio = Math.min((pdfWidth - 40) / imgProps.width, (pdfHeight - 40) / imgProps.height); pdf.addImage(imgData, 'PNG', (pdfWidth - imgProps.width * ratio) / 2, 20, imgProps.width * ratio, imgProps.height * ratio); pdf.save('School_Cost_Comparison.pdf'); } catch (error) { console.error("Error during PDF generation:", error); alert("An error occurred while generating the PDF."); } finally { document.body.removeChild(pdfContentWrapper); } }
Scroll to Top