There is a Change request from the customer. It is as follows:
You need to calculate Interest paid by banks on Saving Account.
Task 1 : Add a function declaration “void CalculateInterest()” in the interface. Define the functions in the concrete classes such as ICICI accounts get 7% interest and HSBC gives 5% interest.
For class ICICI:
public void CalculateInterest()
{
if (AccountType == BankAccountTypeEnum.Saving)
{
double savingsBalance = balance;
savingsBalance *= (1 + (7.0 / 100 / 12));
Console.WriteLine("Balance for ICICI account: {0}", savingsBalance.ToString("C"));
}
else {
Console.WriteLine("Balance for ICICI account: {0}",balance);
}
}
For class HSBC:
public void CalculateInterest()
{
if (AccountType == BankAccountTypeEnum.Saving)
{
double savingsBalance = balance;
savingsBalance *= (1 + (5.0 / 100 / 12));
Console.WriteLine("Balance for HSBC account: {0}", savingsBalance.ToString("C"));
}
else
{
Console.WriteLine("Balance for HSBC account: {0}",balance);
}
}
Comments
Leave a comment