Pricing Calculator

Input Price and Weight

Price (£): Weight (kg): Calculate

// Add hover effect dynamically document.getElementById(‘calculate’).addEventListener(‘mouseover’, function () { this.style.backgroundColor = ‘#0056b3’; }); document.getElementById(‘calculate’).addEventListener(‘mouseout’, function () { this.style.backgroundColor = ‘#007bff’; }); // Calculator functionality document.getElementById(‘calculate’).addEventListener(‘click’, () => { const price = parseFloat(document.getElementById(‘price’).value); const weight = parseFloat(document.getElementById(‘weight’).value); if (isNaN(price) || isNaN(weight)) { document.getElementById(‘total’).textContent = ‘Please enter valid inputs.’; return; } const total = Math.floor((price * 170 + weight * 1600 + 40) / 10) * 10; document.getElementById(‘total’).textContent = `Total Price: BDT ${total}`; });