-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank.java
86 lines (72 loc) · 2.03 KB
/
bank.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
class instruction{
private int acc_no;
private String name;
double balance;
instruction(){
acc_no = 0;
name = "";
balance = 0;
}
void set(int ac, String n, double bal){
acc_no = ac;
name = n;
balance = bal;
}
void showInfo(){
System.out.println("Account Number : " + acc_no);
System.out.println("Account Holder Name : " + name);
System.out.println("Account Balance : " + balance);
}
void deposit(double amount){
balance = balance + amount;
System.out.println("The total Amount in the Account is : " + balance);
}
void withdrawn(double amount){
if(balance>=amount){
balance = balance - amount;
System.out.println("The total Amount in the Account is : " + balance);
}
else{
System.out.println("The total Amount in the Account is : " + balance);
}
}
}
class SavingAccount extends instruction{
private double interestRate;
SavingAccount(double rate){
interestRate = rate;
}
void calculate(){
double a = ((interestRate/100)*balance)+balance;
System.out.println("After the interest : " + a);
}
}
class CheckingAccount extends instruction{
private int cout;
private double fees = 51.265;
CheckingAccount(int cnt){
cout = cnt;
}
void deductf(){
balance = balance - (cout*fees);
System.out.println("The balance after transaction fees. " + balance);
}
}
class bank {
public static void main(String[] args) {
SavingAccount acc = new SavingAccount(5);
acc.set(1023125565,"Akshat",250000);
acc.showInfo();
acc.deposit(1000);
acc.showInfo();
acc.withdrawn(101000);
acc.calculate();
CheckingAccount can = new CheckingAccount(10);
can.set(1023125565,"Akshat",250000);
can.showInfo();
can.deposit(1000);
can.showInfo();
can.withdrawn(101000);
can.deductf();
}
}