You are on page 1of 2

Class Account - ISC COMPUTER PROJECT 2018 1/2

1 class Account
2 {
3 protected int accountnumber;
4 protected double principal;
5
6 public Account( int acno, double prin)
7 {
8 accountnumber=acno;
9 principal=prin;
10 }
11 }
12
13 class Simple extends Account
14 {
15 double rate;
16 int year;
17 public Simple( int ac_number, double principal, double rat
e, int year)
18 {
19 super( ac_number, principal);
20 this.rate=rate;
21 this.year=year;
22 }
23
24 public double interest()
25 {
26 double interest_amount;
27 interest_amount=super.principal*rate*year/100;
28 return interest_amount;
29 }
30
31 public void display()
32 {
33 System.out.println("Account Number= " + super.accountnumber
);
34 System.out.println("Principal= " + super.principal );
35 System.out.println("Rate= " + this.rate );
36 System.out.println("Time= " + this.year );
37 System.out.println("Interest= " + this.interest() );
38 }
39 }
40
41
42 class Compound extends Account
43 {
44 double rate;
45 int year;
46 public Compound( int ac_number, double principal, dou
ble rate, int year)
47 {
48 super(ac_number, principal);
49 this.rate=rate;
50 this.year=year;

5 Aug, 2017 10:12:44 PM


Class Account - ISC COMPUTER PROJECT 2018 (continued) 2/2

51 }
52 public double interest()
53 {
54 double interest_amount;
55 interest_amount= super.principal * Math.pow ( (1+rate/
100), year ) - super.principal;
56 return interest_amount;
57 }
58 public void display()
59 {
60 System.out.println("Account Number= " + super.accountnumber
);
61 System.out.println("Principal= " + super.principal );
62 System.out.println("Rate= " + this.rate );
63 System.out.println("Time= " + this.year );
64 System.out.println("Interest= " + this.interest() );
65 }
66 }
67
68 class Financial
69 {
70 public static void main(String args[])
71 {
72 Simple s=new Simple( 10101, 25000.00, 7.5, 2);
73 s.display();
74
75 System.out.println("**************************************
*********************");
76 Compound c=new Compound( 10102, 25000, 7.5, 2);
77 c.display();
78 }
79 }
80
81

5 Aug, 2017 10:12:44 PM

You might also like