-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank1.java
More file actions
134 lines (99 loc) · 3.53 KB
/
Bank1.java
File metadata and controls
134 lines (99 loc) · 3.53 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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
class BankAccounts {
protected int accNo;
protected String accHoldername;
protected int accBalance;
static final int c=1;
BankAccounts(int accNo, String accHoldername, int accBalance) {
this.accNo = accNo;
this.accHoldername = accHoldername;
this.accBalance = accBalance;
}
public int getAccNo() {
return accNo;
}
public void setAccNo(int accNo) {
this.accNo = accNo;
}
public String getAccHoldername() {
return accHoldername;
}
public BankAccounts getStatement() {
System.out.println("Name:" + getAccHoldername());
System.out.println("Account Type:" + this.getClass().getSimpleName());
return new BankAccounts(this.accNo,this.accHoldername, this.accBalance);
}
public void setAccHoldername(String accHoldername) {
this.accHoldername = accHoldername;
}
public int getAccBalance() {
return accBalance;
}
public void setAccBalance(int accBalance) {
this.accBalance = accBalance;
}
public String toString() {
return String.format("Account Number: %d %nAccount Holder Name: %s %nAccount Balance: %d", accNo,
accHoldername, accBalance);
}
public void additionFeatures() {
}
}
class SavingAccount extends BankAccounts {
static final double rateOfInterest = 5;
SavingAccount(int accNo, String accHoldername, int accBalance) {
super(accNo, accHoldername, accBalance);
}
public double getRateOfInterest() {
return rateOfInterest;
}
public SavingAccount getStatement() {
System.out.println("Name:" + getAccHoldername());
System.out.println("Account Type:" + this.getClass().getSimpleName());
return new SavingAccount(this.accNo,this.accHoldername, this.accBalance);
}
public double getComputedInterest(int years) {
return rateOfInterest * getAccBalance() * years / 100;
}
public double getYearlyInterest() {
return getComputedInterest(1);
}
@Override
public String toString() {
return super.toString() + "\nRate of Interest: " + rateOfInterest;
}
}
class CurrentAccount extends BankAccounts {
int avgDailyTransaction;
public int getAvgDailyTransaction() {
return avgDailyTransaction;
}
public void setAvgDailyTransaction(int avgDailyTransaction) {
this.avgDailyTransaction = avgDailyTransaction;
}
public CurrentAccount getStatement() {
System.out.println("Name:" + getAccHoldername());
System.out.println("Account Type:" + this.getClass().getSimpleName());
return new CurrentAccount(125, "Krishna", 100, 200);
}
CurrentAccount(int accNo, String accHoldername, int accBalance, int avgDailyTransaction) {
super(accNo, accHoldername, accBalance);
this.avgDailyTransaction = avgDailyTransaction;
}
public int getTotalTransactionAmount(int days) {
return avgDailyTransaction * days;
}
public int getYearlyTransaction() {
return getTotalTransactionAmount(365);
}
@Override
public String toString() {
return super.toString() + "\nAverage Daily Transaction Amount: " + avgDailyTransaction;
}
}
public class Bank1 {
public static void main(String[] args) {
BankAccounts generalAcc = new BankAccounts(233, "Krishna vamsi reddy", 1000);
SavingAccount savingAcc = new SavingAccount(234, "Krishna", 2000);
CurrentAccount currentAcc = new CurrentAccount(235, "Krishna", 3000, 200);
}
}