Skip to content

Commit 51ff096

Browse files
Bank Account simulator.java
1 parent e19edf4 commit 51ff096

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Bank Account simulator.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class Bank {
2+
private double balance = 0;
3+
4+
void deposit(double amt) {
5+
balance += amt;
6+
System.out.println("Deposited: " + amt);
7+
}
8+
9+
void withdraw(double amt) {
10+
if (amt > balance) System.out.println("Insufficient balance!");
11+
else {
12+
balance -= amt;
13+
System.out.println("Withdrawn: " + amt);
14+
}
15+
}
16+
17+
void show() {
18+
System.out.println("Balance = " + balance);
19+
}
20+
}
21+
22+
public class BankApp {
23+
public static void main(String[] args) {
24+
Bank b = new Bank();
25+
b.deposit(5000);
26+
b.withdraw(1200);
27+
b.show();
28+
}
29+
}

0 commit comments

Comments
 (0)