CODE FOR HOTEL BILLING SYSTEM

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hotel Billing System</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background: linear-gradient(45deg, #ff6b6b, #f0f0f0);
            margin: 0;
            padding: 20px;
            color: #333;
        }
        h1 {
            text-align: center;
            color: #fff;
            font-size: 48px;
            animation: glow 1.5s ease-in-out infinite alternate;
        }
        @keyframes glow {
            from {
                text-shadow: 0 0 10px #fff, 0 0 20px #ff6b6b, 0 0 30px #ff6b6b;
            }
            to {
                text-shadow: 0 0 20px #fff, 0 0 30px #ff6b6b, 0 0 40px #ff6b6b;
            }
        }
        .container {
            max-width: 600px;
            margin: 0 auto;
            padding: 20px;
            background-color: #fff;
            border-radius: 15px;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
        }
        label {
            display: block;
            margin: 10px 0 5px;
            font-size: 18px;
            font-weight: bold;
        }
        input, select {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        .btn {
            background-color: #ff6b6b;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 18px;
            transition: background-color 0.3s ease;
        }
        .btn:hover {
            background-color: #e63946;
        }
        .bill-container {
            display: none;
            margin-top: 20px;
            padding: 20px;
            background-color: #f7f7f7;
            border-radius: 10px;
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
        }
        .bill-container p {
            font-size: 16px;
            line-height: 1.6;
        }
        .bill-container .total {
            font-size: 20px;
            font-weight: bold;
        }

        /* Print-specific styling */
        @media print {
            body * {
                visibility: hidden;
            }
            .bill-container, .bill-container * {
                visibility: visible;
            }
            .bill-container {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
            }
        }
    </style>
</head>
<body>
    <h1>Hotel Billing System</h1>
    <div class="container">
        <label for="name">Customer Name:</label>
        <input type="text" id="name" placeholder="Enter your name">

        <label for="email">Email Address:</label>
        <input type="email" id="email" placeholder="Enter your email">

        <label for="room">Select Room Type:</label>
        <select id="room">
            <option value="0">Select a room</option>
            <option value="3000">Deluxe Room - NPR 3000</option>
            <option value="5000">Suite Room - NPR 5000</option>
            <option value="2000">Standard Room - NPR 2000</option>
        </select>

        <label for="nights">Number of Nights:</label>
        <input type="number" id="nights" placeholder="Enter number of nights">

        <button class="btn" onclick="generateBill()">Generate Bill</button>

        <div class="bill-container" id="bill-container">
            <h2>Bill Details</h2>
            <p id="customerName"></p>
            <p id="customerEmail"></p>
            <p id="roomType"></p>
            <p id="nightCount"></p>
            <p class="total" id="totalAmount"></p>
            <button class="btn" onclick="printBill()">Print Bill</button>
        </div>
    </div>

    <script>
        function generateBill() {
            const name = document.getElementById('name').value;
            const email = document.getElementById('email').value;
            const room = document.getElementById('room');
            const roomType = room.options[room.selectedIndex].text;
            const roomPrice = parseInt(room.value);
            const nights = parseInt(document.getElementById('nights').value);
            const totalAmount = roomPrice * nights;

            if (name === "" || email === "" || roomPrice === 0 || isNaN(nights) || nights <= 0) {
                alert("Please fill out all fields correctly.");
                return;
            }

            document.getElementById('customerName').innerText = `Customer Name: ${name}`;
            document.getElementById('customerEmail').innerText = `Email: ${email}`;
            document.getElementById('roomType').innerText = `Room Type: ${roomType}`;
            document.getElementById('nightCount').innerText = `Number of Nights: ${nights}`;
            document.getElementById('totalAmount').innerText = `Total Amount: NPR ${totalAmount}`;

            document.getElementById('bill-container').style.display = 'block';
        }

        function printBill() {
            window.print();
        }
    </script>
</body>
</html>
HTML

Leave a Reply

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

Resize text
Scroll to Top