OneCompiler

InsightZap Calculator

188
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Creation Pricing Calculator</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> /* Basic Reset */ * { box-sizing: border-box; } body { margin: 0; font-family: 'Arial', sans-serif; background-color: #f0f2f5; color: #333; } .container { max-width: 600px; margin: 50px auto; padding: 20px; background-color: #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); } h1, h2, h3 { text-align: center; margin-bottom: 20px; } label { display: block; margin-bottom: 5px; font-weight: bold; } input[type="number"] { width: 100%; padding: 10px; margin-bottom: 15px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; } button { width: 100%; padding: 12px; background-color: #007BFF; color: #fff; border: none; font-size: 16px; border-radius: 4px; cursor: pointer; transition: background-color 0.3s ease; } button:hover { background-color: #0056b3; } .result, .breakdown { margin-top: 20px; padding: 15px; background-color: #e9ecef; border-radius: 4px; } .breakdown table { width: 100%; border-collapse: collapse; } .breakdown th, .breakdown td { border: 1px solid #ccc; padding: 8px; text-align: center; } /* Responsive Styles */ @media (max-width: 600px) { .container { margin: 20px; padding: 15px; } button { font-size: 14px; } } </style> </head> <body> <div class="container"> <h1>Creation Pricing Calculator</h1> <label for="creations">Enter number of creations:</label> <input type="number" id="creations" min="0" value="0"> <button onclick="calculatePrice()">Calculate Price</button>
<div class="result" id="result"></div>
<div class="breakdown" id="breakdown"></div>
</div> <script> function calculatePrice() { var num = parseInt(document.getElementById("creations").value, 10); var totalCost = 0; var breakdownDetails = []; if (num <= 25) { // If creations are 25 or less, they're all free. breakdownDetails.push({ tier: "Tier 1 (1-25)", units: num, rate: "$0", cost: "$0" }); } else { // Tier 1: First 25 are free. breakdownDetails.push({ tier: "Tier 1 (1-25)", units: 25, rate: "$0", cost: "$0" }); // Tier 2: 26-75 at $180 each. if (num > 25) { var tier2Units = Math.min(num, 75) - 25; var tier2Cost = tier2Units * 180; totalCost += tier2Cost; breakdownDetails.push({ tier: "Tier 2 (26-75)", units: tier2Units, rate: "$180", cost: "$" + tier2Cost }); } // Tier 3: 76-150 at $120 each. if (num > 75) { var tier3Units = Math.min(num, 150) - 75; var tier3Cost = tier3Units * 120; totalCost += tier3Cost; breakdownDetails.push({ tier: "Tier 3 (76-150)", units: tier3Units, rate: "$120", cost: "$" + tier3Cost }); } // Tier 4: 151-300 at $60 each. if (num > 150) { var tier4Units = Math.min(num, 300) - 150; var tier4Cost = tier4Units * 60; totalCost += tier4Cost; breakdownDetails.push({ tier: "Tier 4 (151-300)", units: tier4Units, rate: "$60", cost: "$" + tier4Cost }); } // Tier 5: Above 300 at $24 each. if (num > 300) { var tier5Units = num - 300; var tier5Cost = tier5Units * 24; totalCost += tier5Cost; breakdownDetails.push({ tier: "Tier 5 (301+)", units: tier5Units, rate: "$24", cost: "$" + tier5Cost }); } } // Display the total price document.getElementById("result").innerHTML = "<h2>Total Price: $" + totalCost + "</h2>"; // Build the breakdown table var breakdownHTML = "<h3>Cost Breakdown:</h3><table><tr><th>Tier</th><th>Units</th><th>Rate</th><th>Cost</th></tr>"; breakdownDetails.forEach(function(item) { breakdownHTML += "<tr><td>" + item.tier + "</td><td>" + item.units + "</td><td>" + item.rate + "</td><td>" + item.cost + "</td></tr>"; }); breakdownHTML += "</table>"; document.getElementById("breakdown").innerHTML = breakdownHTML; } </script> </body> </html>