forked from seeditsolution/javaprogram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbanking-application
More file actions
69 lines (68 loc) · 1.1 KB
/
banking-application
File metadata and controls
69 lines (68 loc) · 1.1 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
class Account
{
int accno,balance;
void chckbalance()
{
System.out.println("Your Balance is : "+balance);
}
void deposit(int value)
{
balance=balance+value;
System.out.println("Deposited successfully.");
}
void withdraw(int value)
{
if (value>balance)
{
System.out.println("Insufficient balance.");
}
else
{
balance=balance-value;
System.out.println("Withdrawl successfully.");
}
}
}
class Saving extends Account
{
double interestrate;
Saving(double value)
{
interestrate=value;
}
}
class Current extends Account
{
int overdraftlimit;
Current(int value)
{
overdraftlimit=value;
}
void withdraw(int value)
{
if (value>balance && value>overdraftlimit)
{
System.out.println("Insufficient balance.");
}
else
{
balance=balance-value;
System.out.println("Withdrawl successfully.");
}
}
}
public class p15
{
public static void main(String[] args) {
Saving s=new Saving(2.5);
Current c=new Current(100);
s.deposit(500);
s.chckbalance();
c.deposit(300);
c.chckbalance();
s.withdraw(200);
s.chckbalance();
c.withdraw(350);
c.chckbalance();
}
}