CODE FOR SIMPLE INTERST CALCULATOR

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Simple Interest Calculator</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(to right, #f06, #00c6ff);
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            overflow: hidden;
        }

        .container {
            background-color: #fff;
            padding: 40px;
            border-radius: 15px;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
            width: 350px;
            text-align: center;
            position: relative;
            overflow: hidden;
        }

        .container::before {
            content: '';
            position: absolute;
            width: 200%;
            height: 100%;
            background: #00c6ff;
            z-index: -1;
            top: 0;
            left: -100%;
            transform: translateX(0%);
            transition: all 1s ease;
        }

        .container:hover::before {
            transform: translateX(100%);
        }

        h1 {
            color: #333;
            margin-bottom: 20px;
        }

        input, button {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            border-radius: 5px;
            border: 1px solid #ccc;
            outline: none;
        }

        button {
            background-color: #00c6ff;
            color: white;
            border: none;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.5s ease;
        }

        button:hover {
            background-color: #005f73;
        }

        .result {
            margin-top: 20px;
            font-size: 18px;
            color: #333;
            display: none;
        }

        /* Animations */
        .slide-down {
            animation: slideDown 0.5s ease-out forwards;
        }

        @keyframes slideDown {
            from {
                opacity: 0;
                transform: translateY(-30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .fade {
            animation: fadeIn 1.2s ease-out forwards;
        }

        @keyframes fadeIn {
            0% { opacity: 0; }
            100% { opacity: 1; }
        }
    </style>
</head>
<body>

    <div class="container fade">
        <h1>Simple Interest Calculator</h1>
        <input type="number" id="principal" placeholder="Enter Principal Amount" required>
        <input type="number" id="rate" placeholder="Enter Interest Rate (%)" required>
        <input type="number" id="time" placeholder="Enter Time (Years)" required>
        <button onclick="calculateInterest()">Calculate</button>
        <div class="result slide-down" id="result"></div>
    </div>

    <script>
        function calculateInterest() {
            let principal = document.getElementById("principal").value;
            let rate = document.getElementById("rate").value;
            let time = document.getElementById("time").value;

            if (principal === '' || rate === '' || time === '') {
                alert("Please fill out all fields.");
                return;
            }

            let interest = (principal * rate * time) / 100;
            let totalAmount = parseFloat(principal) + interest;

            document.getElementById("result").innerHTML = 
                `<p>Simple Interest: NPR ${interest.toFixed(2)}</p>
                 <p>Total Amount: NPR ${totalAmount.toFixed(2)}</p>`;
            document.getElementById("result").style.display = "block";
        }
    </script>

</body>
</html>
Bash

Leave a Reply

Your email address will not be published. Required fields are marked *

Resize text
Scroll to Top