CURRENCY CONVERTOR CALCULATOR

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

        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(135deg, #89fffd, #ef32d9);
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            overflow: hidden;
        }

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

        .container::before {
            content: '';
            position: absolute;
            width: 150%;
            height: 150%;
            background: radial-gradient(circle, rgba(239,50,217,1) 0%, rgba(137,255,253,1) 100%);
            top: -50%;
            left: -50%;
            z-index: -1;
            transform: rotate(45deg);
            transition: all 1.5s ease;
        }

        .container:hover::before {
            transform: rotate(-45deg);
        }

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

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

        button {
            background-color: #ef32d9;
            color: white;
            padding: 10px;
            width: 100%;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s ease;
        }

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

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

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

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

    <div class="container fade">
        <h1>Currency Converter</h1>
        <input type="number" id="amount" placeholder="Enter Amount" required>
        <select id="fromCurrency">
            <option value="USD" selected>USD ($)</option>
            <option value="EUR">EUR (€)</option>
            <option value="GBP">GBP (£)</option>
            <option value="NPR">NPR (₨)</option>
        </select>

        <select id="toCurrency">
            <option value="USD">USD ($)</option>
            <option value="EUR" selected>EUR (€)</option>
            <option value="GBP">GBP (£)</option>
            <option value="NPR">NPR (₨)</option>
        </select>

        <button onclick="convertCurrency()">Convert</button>
        <div class="result" id="result"></div>
    </div>

    <script>
        const conversionRates = {
            USD: { EUR: 0.94, GBP: 0.82, NPR: 132.50, USD: 1 },
            EUR: { USD: 1.06, GBP: 0.87, NPR: 140.84, EUR: 1 },
            GBP: { USD: 1.22, EUR: 1.15, NPR: 162.20, GBP: 1 },
            NPR: { USD: 0.0075, EUR: 0.0071, GBP: 0.0062, NPR: 1 }
        };

        function convertCurrency() {
            let amount = document.getElementById("amount").value;
            let fromCurrency = document.getElementById("fromCurrency").value;
            let toCurrency = document.getElementById("toCurrency").value;

            if (amount === '') {
                alert("Please enter an amount");
                return;
            }

            let convertedAmount = (amount * conversionRates[fromCurrency][toCurrency]).toFixed(2);

            document.getElementById("result").innerHTML = 
                `<p>${amount} ${fromCurrency} = ${convertedAmount} ${toCurrency}</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