Profit Margin Calculator (Soup)
Calculate the profit margin for your soup business.
function calculateProfitMargin() { const costOfGoods = parseFloat(document.getElementById(“costOfGoods”).value); const sellingPrice = parseFloat(document.getElementById(“sellingPrice”).value); if (isNaN(costOfGoods) || isNaN(sellingPrice) || costOfGoods <= 0 || sellingPrice <= 0) { alert("Please enter valid positive values for both fields."); return; } const profitMargin = ((sellingPrice – costOfGoods) / sellingPrice) * 100; document.getElementById("profitMarginResult").value = profitMargin.toFixed(2) + "%"; }