-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankAccount.java
More file actions
70 lines (46 loc) · 1.34 KB
/
Copy pathBankAccount.java
File metadata and controls
70 lines (46 loc) · 1.34 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class BankAccount {
String accountNumber;
String holderName;
private double balance;
public BankAccount(String accountNumber, String holderName, double balance) {
this.accountNumber = accountNumber;
this.holderName = holderName;
this.balance = balance;
}
public void deposit(double ammount){
if(ammount>0) {
balance+=ammount;
System.out.println("Your deposited ammount is "+ammount);
}
else {
System.out.println("you deposite 0 ammount.");
}
}
public void withdraw(double ammount) {
if(ammount>0 && ammount<=balance) {
balance-=ammount;
System.out.println("your deposited ammount is "+ammount);
}
else {
System.out.println("Insufficent balance in account.");
}
}
public void checkBalance() {
System.out.println("Current balance is "+balance);
}
}
class MainClass {
public static void main (String[]args) {
BankAccount b1 =new BankAccount( "ABC14520kk","Soumya",7000);
// checking initial balance
b1.checkBalance();
// depositing money
b1.deposit(2000);
// checking balance
b1.checkBalance();
// withdrawing money
b1.withdraw(1500);
// checking balance
b1.checkBalance();
}
}