CODE FOR INFLATION RATE CALCULATOR

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Inflation Rate Calculator</title>
    <style>
        /* General styling */
        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(to right, #ffecd2, #fcb69f);
            color: #333;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            overflow: hidden;
        }

        /* Container box styling */
        .container {
            text-align: center;
            background: rgba(255, 255, 255, 0.9);
            padding: 30px;
            border-radius: 15px;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
            animation: fadeIn 2s ease-in-out;
        }

        /* Title animation */
        .title {
            font-size: 2.5em;
            font-weight: bold;
            color: #ff6f61;
            animation: titleAnimation 3s infinite alternate;
        }

        @keyframes titleAnimation {
            from {
                transform: scale(1);
            }
            to {
                transform: scale(1.1);
            }
        }

        /* Calculator box styling */
        .calculator-box {
            margin-top: 20px;
        }

        label {
            font-size: 1.1em;
            margin-right: 10px;
        }

        input[type="number"] {
            padding: 10px;
            margin: 10px 0;
            border: 2px solid #ff6f61;
            border-radius: 10px;
            width: 80%;
            font-size: 1em;
        }

        button {
            padding: 10px 20px;
            background-color: #ff6f61;
            color: white;
            border: none;
            border-radius: 10px;
            cursor: pointer;
            font-size: 1.2em;
            transition: background-color 0.3s ease;
        }

        button:hover {
            background-color: #ff856c;
        }

        /* Result styling */
        .result {
            margin-top: 20px;
            font-size: 1.5em;
            font-weight: bold;
            color: #333;
        }

        /* Animated text */
        .animated-text {
            color: #ff856c;
            font-size: 1.2em;
            margin-bottom: 15px;
            animation: moveText 3s ease-in-out infinite;
        }

        @keyframes moveText {
            0% { transform: translateX(0); }
            50% { transform: translateX(20px); }
            100% { transform: translateX(0); }
        }

        /* Animated image */
        .animated-image {
            width: 100px;
            margin-top: 20px;
            animation: bounce 2s infinite;
        }

        @keyframes bounce {
            0%, 100% {
                transform: translateY(0);
            }
            50% {
                transform: translateY(-20px);
            }
        }

        /* Fade in animation for the container */
        @keyframes fadeIn {
            from {
                opacity: 0;
            }
            to {
                opacity: 1;
            }
        }
    </style>
</head>
<body>

    <div class="container">
        <h1 class="title">Inflation Rate Calculator</h1>
        <p class="animated-text">Calculate how inflation affects your money!</p>

        <div class="calculator-box">
            <label for="initial-value">Initial Value (NPR): </label>
            <input type="number" id="initial-value" placeholder="Enter initial amount">

            <label for="current-value">Current Value (NPR): </label>
            <input type="number" id="current-value" placeholder="Enter current amount">

            <button onclick="calculateInflation()">Calculate Inflation Rate</button>

            <div id="result" class="result"></div>
        </div>

        <img src="https://staxbill.com/wp-content/uploads/2019/05/Price-Increase-Strategy-1024x659.jpeg" class="animated-image" alt="Inflation Image">
    </div>

    <script>
        function calculateInflation() {
            // Get values from the input fields
            let initialValue = parseFloat(document.getElementById('initial-value').value);
            let currentValue = parseFloat(document.getElementById('current-value').value);

            // Validate the input values
            if (isNaN(initialValue) || isNaN(currentValue) || initialValue <= 0 || currentValue <= 0) {
                document.getElementById('result').innerHTML = "Please enter valid amounts!";
                return;
            }

            // Calculate the inflation rate
            let inflationRate = ((currentValue - initialValue) / initialValue) * 100;

            // Display the result
            document.getElementById('result').innerHTML = `Inflation Rate: ${inflationRate.toFixed(2)}%`;
        }
    </script>

</body>
</html>
HTML

Leave a Reply

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

Resize text
Scroll to Top