Assignment 3
Assignment 3
Faculty of Business
MIS Department
Business Software Development
Assignment 3
Base class Account should include one private instance variable of type
decimal to represent the account balance. The class should provide a
constructor that receives an initial balance and uses it to initialize the
instance variable with a public property. The property should validate the
initial balance to ensure that it’s greater than or equal to 0.0; if not, throw
an exception.
The class should provide two public methods. Method Credit should add
an amount to the current balance. Method Debit should withdraw money
from the Account and ensure that the debit amount does not exceed the
Account’s balance. SavingsAccount class include a decimal instance
variable indicating the interest rate (percentage) assigned to the Account.
SavingsAccount’s constructor should receive the initial balance, as well as
an initial value for the interest rate. SavingsAccount should provide public
method CalculateInterest that returns a decimal indicating the amount of
interest earned by an account.
Write an app that creates objects and tests their methods. Add interest to
the SavingsAccount object by first invoking its CalculateInterest method,
then passing the returned interest amount to the object’s Credit method.