Professional Documents
Culture Documents
Banking Exercise
Banking Exercise
a) Define a class Account, has account number and balance as class-members. Account
class must have following methods
a.1) Deposit: Deposit method accept amount as parameter and add amount in balance
field.
a.2) Withdraw: Withdraw method accept amount as a parameter and deduct the amount
from balance field. Proper exception handling must be in place to make sure
customer account balance must not be in negative.
a.3) getBalance : method returns the account balance.
b) Define SavingsAccount class, extend Account class and must have interestRate as
class-member. SavingsAccount must have following methods.
b.1)SavingsAccount constructor must accept account number and interest rate as
parameter.
b.2) calculateInterest : method must return the balance multiply by interest rate.
c) Define CheckingAccount class, extend Account class and must have overdraftLimit
as class-member. CheckingAccount must have following methods.
c.1)CheckingAccount constructor must accept account number and overdraftLimit as
parameter.