-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbank.java
More file actions
75 lines (69 loc) · 1.28 KB
/
bank.java
File metadata and controls
75 lines (69 loc) · 1.28 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
abstract class bank
{
int accno;
double bal;
void deposit(double amt)
{
bal += amt;
System.out.println("Amount debited - "+ amt);
System.out.println("Current balance - "+bal);
}
abstract void withdrawal(double amt);
}
class savings extends bank
{
double rate;
savings(int ac,double bal,double rate)
{
accno=ac;
deposit(bal);
}
@Override
void withdrawal(double amt)
{
if((bal-amt)>=10000)
{
bal -= amt;
System.out.println("Amount credited - "+ amt);
System.out.println("Current balance - "+bal);
}
else
System.out.println("Limit exceeded !");
}
void intCalc()
{
bal += bal*rate*0.01;
}
}
class current extends bank
{
double fine;
current(int ac,double bal, double fine)
{
accno = ac;
deposit(bal);
this.fine = fine;
}
@Override
void withdrawal(double amt)
{
bal -= amt;
if( bal <= -20000)
bal += fine*0.01*(bal+20000);
System.out.println("Amount credited - "+ amt);
System.out.println("Current balance - "+bal);
}
}
class Main
{
public static void main(String args[])
{
System.out.println("---SAVINGS ACCOUNT---");
savings sc = new savings(1453232,15000,5);
sc.intCalc();
sc.withdrawal(12000);
System.out.println("---CURRENT ACCOUNT---");
current curr = new current(1453223,10000,5);
curr.withdrawal(35000);
}
}