## Monday, January 14, 2013

### ISC - Inheritance

#### 1 comment:

1. A financial Institution has only two kinds of Accounts, Simple and Compound.

The class Account has two protected attributes Account Number (a positive integer) and Principle (a double precision real number to store the money deposited initially).

The interest for a Simple Account is calculated by using the Simple Interest formula: SI=PRT/100, where SI=Simple Interest, P=Principle, R=Rate of Interest per annum, T=Time in year.

The interest for a Compound Account is calculated by using the Compound Interest formula. CI=P[1+R/100]T - P, where CI=Compound Interest, P=Principle, R=Rate of Interest per annum, T=Time in year.
Rate and Time for two types of account may vary. Model the above situation by defining classes Account, Simple and Compound, where Simple and Compound are derived classes from class Account.

Write appropriate constructors for passing various attributes for the three classes. Write the function double interest() that calculates the appropriate interest and return the interest for the classes Simple and Compound. Also write the function display() for the three classes which print out all the attributes values as.

Account Number:

Principle:

Rate:

Time:

Interest:

with each attribute on a single line. Make sure that each display() function is correctly placed in the appropriate class. You need to write the main function.