Pages

Friday, 20 December 2024

Dividend Calculator Tool



Dividend Calculator

Dividend Calculator

Total Dividend Income: $0.00

* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Poppins', sans-serif; background: linear-gradient(135deg, #6a11cb, #2575fc); color: #fff; display: flex; justify-content: center; align-items: center; height: 100vh; } .container { background-color: rgba(0, 0, 0, 0.6); border-radius: 10px; padding: 40px; max-width: 400px; width: 100%; } h1 { text-align: center; margin-bottom: 30px; font-weight: 600; } .calculator-form { display: flex; flex-direction: column; } label { font-weight: 400; margin-bottom: 5px; } input { padding: 10px; margin-bottom: 15px; border-radius: 5px; border: 2px solid #fff; background: #333; color: #fff; font-size: 16px; } button { background-color: #2575fc; color: #fff; border: none; padding: 15px; border-radius: 5px; font-size: 16px; cursor: pointer; transition: background-color 0.3s ease; } button:hover { background-color: #6a11cb; } .result { margin-top: 20px; text-align: center; font-size: 20px; font-weight: 600; } function calculateDividend() { const stockPrice = parseFloat(document.getElementById('stockPrice').value); const dividendPerShare = parseFloat(document.getElementById('dividendPerShare').value); const numShares = parseInt(document.getElementById('numShares').value); // Check for valid inputs if (isNaN(stockPrice) || isNaN(dividendPerShare) || isNaN(numShares) || stockPrice <= 0 || dividendPerShare <= 0 || numShares <= 0) { alert('Please enter valid positive numbers for all fields.'); return; } const totalDividend = dividendPerShare * numShares; // Display the result document.getElementById('totalDividend').textContent = `Total Dividend Income: $${totalDividend.toFixed(2)}`; }