Pages

Wednesday, 27 November 2024

Discounted Cash Flow Calculator Tool

Discounted Cash Flow Calculator

Discounted Cash Flow (DCF) Calculator

Calculate the present value of future cash flows

Results:

Net Present Value (NPV): $

body { background-color: #f8f9fa; font-family: Arial, sans-serif; } .card { border-radius: 10px; background: linear-gradient(145deg, #ffffff, #e6e6e6); } .btn-primary { background: #007bff; border: none; transition: 0.3s; } .btn-primary:hover { background: #0056b3; transform: scale(1.05); } #results { background-color: #d4edda; border: 1px solid #c3e6cb; padding: 15px; border-radius: 10px; } document.getElementById('dcfForm').addEventListener('submit', function (e) { e.preventDefault(); // Get user inputs const cashFlows = document.getElementById('cashFlows').value.split(',').map(Number); const discountRate = parseFloat(document.getElementById('discountRate').value) / 100; const growthRate = parseFloat(document.getElementById('growthRate').value) / 100; const terminalValue = parseFloat(document.getElementById('terminalValue').value); // Calculate NPV let npv = 0; for (let i = 0; i < cashFlows.length; i++) { npv += cashFlows[i] / Math.pow(1 + discountRate, i + 1); } // Add terminal value const terminalValueDiscounted = terminalValue / Math.pow(1 + discountRate, cashFlows.length); npv += terminalValueDiscounted; // Display result document.getElementById('npv').textContent = npv.toFixed(2); document.getElementById('results').classList.remove('d-none'); });