Skip to content

Commit 8aa5be3

Browse files
Bank
1 parent 17bf034 commit 8aa5be3

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

BankAccount.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.util.*;
2+
3+
class BankAccount {
4+
String name;
5+
int accNo;
6+
double balance;
7+
8+
BankAccount(String n, int a, double b) {
9+
name = n; accNo = a; balance = b;
10+
}
11+
12+
void deposit(double amt) { balance += amt; }
13+
void withdraw(double amt) {
14+
if (amt <= balance) balance -= amt;
15+
else System.out.println("Insufficient balance");
16+
}
17+
18+
void display() {
19+
System.out.println(name+" | "+accNo+" | Balance: "+balance);
20+
}
21+
}
22+
23+
public class BankSystem {
24+
public static void main(String[] args) {
25+
BankAccount acc = new BankAccount("User",101,1000);
26+
acc.deposit(500);
27+
acc.withdraw(300);
28+
acc.display();
29+
}
30+
}

0 commit comments

Comments
 (0)