-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankAccount.html
More file actions
56 lines (44 loc) · 1.38 KB
/
Copy pathBankAccount.html
File metadata and controls
56 lines (44 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<title>Bank Account</title>
</head>
<body>
<script>
class BankAccount {
constructor(accountNo, holderName, balance) {
this.accountNo = accountNo;
this.holderName = holderName;
this.balance = balance;
}
deposit(amount) {
this.balance += amount;
}
withdraw(amount) {
if (amount <= this.balance) {
this.balance -= amount;
} else {
document.write("<br>Insufficient Balance");
}
}
display() {
document.write("<br><b>Account Number:</b> " + this.accountNo);
document.write("<br><b>Holder Name:</b> " + this.holderName);
document.write("<br><b>Balance:</b> ₹" + this.balance);
}
}
let accountNo = prompt("Enter Account Number:");
let holderName = prompt("Enter Holder Name:");
let balance = parseFloat(prompt("Enter Initial Balance:"));
let acc = new BankAccount(accountNo, holderName, balance);
document.write("<b>Initial Details</b>");
acc.display();
let dep = parseFloat(prompt("Enter amount to deposit:"));
acc.deposit(dep);
let wit = parseFloat(prompt("Enter amount to withdraw:"));
acc.withdraw(wit);
document.write("<br><br><b>Updated Details</b>");
acc.display();
</script>
</body>
</html>