Answer to Question #240049 in C# for Gayatri

Question #240049

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.


1
Expert's answer
2021-09-23T04:49:23-0400
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);
            }
        }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS