Continuous Compound Interest

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Continuous Compound Interest Calculator</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 600px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f4f4f4;
        }
        h1 {
            text-align: center;
            color: #333;
        }
        form {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        input {
            width: 100%;
            padding: 8px;
            margin-bottom: 15px;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        .buttons {
            display: flex;
            justify-content: space-between;
            margin-top: 10px;
        }
        button {
            width: 45%;
            padding: 10px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        button:hover {
            background-color: #45a049;
        }
        button.reset {
            background-color: #f44336;
        }
        button.reset:hover {
            background-color: #da190b;
        }
        #result {
            margin-top: 20px;
            font-size: 18px;
            font-weight: bold;
            text-align: center;
            color: #333;
        }
        .explanation {
            margin-bottom: 20px;
            line-height: 1.5;
        }
    </style>
</head>
<body>
    <h1>Continuous Compound Interest Calculator</h1>
    <div class="explanation">
        <p>The formula for continuous compound interest is <strong>A = P e<sup>rt</sup></strong>, where:</p>
        <ul>
            <li><strong>A</strong> is the final amount.</li>
            <li><strong>P</strong> is the principal (initial amount).</li>
            <li><strong>e</strong> is the mathematical constant (approximately 2.71828).</li>
            <li><strong>r</strong> is the annual interest rate (as a decimal, e.g., 5% = 0.05).</li>
            <li><strong>t</strong> is the time in years.</li>
        </ul>
        <p>This formula calculates interest compounded infinitely, meaning it's always growing, unlike standard compounding.</p>
    </div>
    <form id="calcForm">
        <label for="principal">Principal (P):</label>
        <input type="number" id="principal" min="0" step="0.01" required placeholder="e.g., 1000">

        <label for="rate">Annual Interest Rate (r, as decimal):</label>
        <input type="number" id="rate" min="0" step="0.001" required placeholder="e.g., 0.05 for 5%">

        <label for="time">Time (t, in years):</label>
        <input type="number" id="time" min="0" step="0.1" required placeholder="e.g., 5">

        <div class="buttons">
            <button type="button" onclick="calculate()">Calculate</button>
            <button type="button" class="reset" onclick="resetForm()">Reset</button>
        </div>
    </form>
    <p id="result"></p>

    <script>
        function calculate() {
            const principal = parseFloat(document.getElementById('principal').value);
            const rate = parseFloat(document.getElementById('rate').value);
            const time = parseFloat(document.getElementById('time').value);

            if (isNaN(principal) || isNaN(rate) || isNaN(time) || principal < 0 || rate < 0 || time < 0) {
                document.getElementById('result').innerText = 'Please enter valid positive numbers for all fields.';
                return;
            }

            const amount = principal * Math.exp(rate * time);
            document.getElementById('result').innerText = `Final Amount (A): $${amount.toFixed(2)}`;
        }

        function resetForm() {
            document.getElementById('principal').value = '';
            document.getElementById('rate').value = '';
            document.getElementById('time').value = '';
            document.getElementById('result').innerText = '';
        }
    </script>
</body>
</html>

Copy the above code to a text editor like Notepad or Notepad++ and save as index.html. Open the web page.