File tree Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ class Account
2
+ {
3
+ int accno,balance;
4
+ void chckbalance()
5
+ {
6
+ System.out.println("Your Balance is : "+balance);
7
+ }
8
+ void deposit(int value)
9
+ {
10
+ balance=balance+value;
11
+ System.out.println("Deposited successfully.");
12
+ }
13
+ void withdraw(int value)
14
+ {
15
+ if (value>balance)
16
+ {
17
+ System.out.println("Insufficient balance.");
18
+ }
19
+ else
20
+ {
21
+ balance=balance-value;
22
+ System.out.println("Withdrawl successfully.");
23
+ }
24
+ }
25
+ }
26
+ class Saving extends Account
27
+ {
28
+ double interestrate;
29
+ Saving(double value)
30
+ {
31
+ interestrate=value;
32
+ }
33
+ }
34
+ class Current extends Account
35
+ {
36
+ int overdraftlimit;
37
+ Current(int value)
38
+ {
39
+ overdraftlimit=value;
40
+ }
41
+ void withdraw(int value)
42
+ {
43
+ if (value>balance && value>overdraftlimit)
44
+ {
45
+ System.out.println("Insufficient balance.");
46
+ }
47
+ else
48
+ {
49
+ balance=balance-value;
50
+ System.out.println("Withdrawl successfully.");
51
+ }
52
+ }
53
+ }
54
+ public class p15
55
+ {
56
+ public static void main(String[] args) {
57
+
58
+ Saving s=new Saving(2.5);
59
+ Current c=new Current(100);
60
+ s.deposit(500);
61
+ s.chckbalance();
62
+ c.deposit(300);
63
+ c.chckbalance();
64
+ s.withdraw(200);
65
+ s.chckbalance();
66
+ c.withdraw(350);
67
+ c.chckbalance();
68
+ }
69
+ }
You can’t perform that action at this time.
0 commit comments