-
Notifications
You must be signed in to change notification settings - Fork 168
/
Banking Management System.java
116 lines (96 loc) · 3.62 KB
/
Banking Management System.java
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//------ AI Programming ---------
// Banking system
// Join our underground coding movement @freecodecs (c) Dec, 2019.
interface Account{
double deposit = 0;
double balance = 0;
double rate = 0;
double withdraw = 0;
public double interestCalc();
}
class SavingAccount implements Account{
double deposit;
double balance;
double rate = .08;
double withdraw;
public void deposit(double dipo){
balance += dipo;
}
public double interestCalc(){
return (balance * rate);
}
public void withdraw(double wdraw) {
if(wdraw > (balance * .8)){
System.out.println("Only below 80% of balance withdrawal is acceptable");
}
else {
withdraw = (wdraw * 0.05);
System.out.println("The withdrawal charge : " + withdraw);
balance -= (withdraw + wdraw);
}
}
}
class CurrentAccount implements Account {
double deposit;
double balance;
double rate = .12;
double withdraw;
public void deposit(double dip) {
balance += dip;
}
public double interestCalc() {
return (balance * rate);
}
public void withdraw(double wdraw){
if(wdraw < 2000)
System.out.println("Minimum withdrawal is 2000!");
else {
if(wdraw > (balance *.9)){
System.out.println("Only Below 90% of balance withdrawal is acceptable");
}
else
balance -= (withdraw + wdraw);
}
}
}
public class Bank {
public static void main(String[] args) {
SavingAccount savAcc=new SavingAccount();
CurrentAccount curAcc=new CurrentAccount();
//Abebe open deposit wiz initial 1000
savAcc.deposit(1000);
System.out.println("Abebe's Initial Balance : " + savAcc.balance);
//make diposits at different times
System.out.println("Dipositing 1,500 / 500 / 2,000 Amounts");
savAcc.deposit(1500);
savAcc.deposit(500);
savAcc.deposit(2000);
System.out.println("Abebe's Saving Account Balance : " + savAcc.balance);
System.out.println("He's Interest Amount : " + savAcc.interestCalc());
savAcc.balance += savAcc.interestCalc();
System.out.println("Balance : " + savAcc.balance);
//Making withrawals from Saving Account
System.out.println("Withdrawals of 2,000 / 800 / 1,000 Amounts");
savAcc.withdraw(2000);
savAcc.withdraw(800);
savAcc.withdraw(1000);
//Display Net Balance
System.out.println("Abebe's net balance : " + savAcc.balance);
System.out.println("---------------------------------------\n");
//Aster open account wiz initial 5000
curAcc.deposit(5000);
System.out.println("Aster's Initial Balance : " + curAcc.balance);
System.out.println("Dipositing 2,500 & 3,000 Amounts");
curAcc.deposit(2500);
curAcc.deposit(3000);
// after depositing 2500 & 3000
System.out.println("Her Current Account Balance : " + curAcc.balance);
System.out.println("Interest Amount : " + curAcc.interestCalc());
curAcc.balance += curAcc.interestCalc();
System.out.println("Balance : " + curAcc.balance);
System.out.println("Withdrawals of 4,000 & 2,5000 Amounts");
curAcc.withdraw(4000);
curAcc.withdraw(2500);
System.out.println("Aster's net balance : " + curAcc.balance);
}
}