New code


<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Bank Account Withdrawal</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; margin: 0; padding: 0; }
h2 {
  color: #333;
  text-align: center;
  margin-top: 30px;
}

.container {
  width: 50%;
  margin: 0 auto;
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

label {
  font-weight: bold;
}

input[type="number"] {
  width: 100%;
  padding: 8px;
  margin: 5px 0;
  border: 1px solid #ccc;
  border-radius: 4px;
}

button {
  padding: 10px 20px;
  margin-top: 10px;
  background-color: #007bff;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background-color: #0056b3;
}

#result {
  margin-top: 20px;
  padding: 10px;
  border-radius: 4px;
  background-color: #f0f0f0;
}
</style> </head> <body> <h2>Bank Account Withdrawal</h2> <div class="container"> <div> <label for="balance">Account Balance:</label> <input type="number" id="balance" placeholder="Enter account balance" value="10000"> </div> <div> <label for="amount">Withdrawal Amount:</label> <input type="number" id="amount" placeholder="Enter withdrawal amount"> </div>

<button onclick="withdraw()">Withdraw</button>
<button onclick="checkBalance()">Check Balance</button>

<div id="result"></div> </div> <script> let remainingBalance = 10000; // Set initial balance function withdraw() { const balanceInput = document.getElementById("balance"); const balance = parseFloat(balanceInput.value); const amount = parseFloat(document.getElementById("amount").value); if (isNaN(balance) || isNaN(amount)) { document.getElementById("result").innerText = "Please enter valid numbers."; return; } if (amount < 1000) { document.getElementById("result").innerText = "Minimum amount that can be withdrawn is 1000."; return; } if (amount > balance) { document.getElementById("result").innerText = "Insufficient funds."; return; } remainingBalance = balance - amount; balanceInput.value = remainingBalance; // Update balance input field if (remainingBalance < 500) { document.getElementById("result").innerText = "Minimum balance should be 500. Remaining balance: " + remainingBalance; } else { document.getElementById("result").innerText = `Withdrawn ${amount} successfully. Remaining balance: ${remainingBalance}`; } } function checkBalance() { document.getElementById("result").innerText = `Current Balance: ${remainingBalance}`; } </script> </body> </html>