WAP to find the simple interest of given Principal, Time and Rate of interest.


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Simple Interest Calculator</title>
    <script>
        function calculateInterest() {
            // Get values from the input fields
            const principal = parseFloat(document.getElementById('principal').value);
            const time = parseFloat(document.getElementById('time').value);
            const rate = parseFloat(document.getElementById('rate').value);
            // Calculate simple interest
            const simpleInterest = (principal * time * rate) / 100;
            // Display the reAsult
            document.getElementById('result').innerHTML = `
                <h2>Simple Interest Calculation</h2>
                <p>Principal Amount: $${principal}</p>
                <p>Time: ${time} years</p>
                <p>Rate of Interest: ${rate}%</p>
                <p>Simple Interest: $${simpleInterest.toFixed(2)}</p>
            `;
        }
    </script>
</head>
<body>
    <h2>Simple Interest Calculator</h2>
    <form onsubmit="event.preventDefault(); calculateInterest();">
        Principal Amount: <input type="number" id="principal" required><br>
        Time (in years): <input type="number" id="time" required><br>
        Rate of Interest (in %): <input type="number" id="rate" required><br>
        <button type="submit">Calculate Simple Interest</button>
    </form>
    <div id="result"></div>
</body>
</html>

x

Post a Comment

0 Comments