Answer to Question #330057 in C# for madhu

Question #330057

.Write a class called LoanProcess with Loan_ No, Customer Name, LoanAmount, EMI_ Amount, Account_Balance as its members. Create a method calculate_EMI() for the LoanAmount, with the rate of interest as 13% for a total of 3 years and store it in the EMI_ Amount. The rest of the information to be passed through constructors. Write another function CheckBalance() which checks if the Account Balance is less than the EMI_AMount. If yes then throw a custom exception. Display "Not Sufficient Balance to repay Loan" in the finally. Give explanatory comments.


1
Expert's answer
2022-04-19T08:07:04-0400
public class LoanProcess
{
   private const int YEARS_COUNT = 3;
   private const double INTEREST_RATE = 12;

   public LoanProcess(int loadNo, string customerName, int loanAmount, int accountBalance)
   {
      Load_No = loadNo;
      CustomerName = customerName;
      LoanAmount = loanAmount;
      AccountBalance = accountBalance;
   }

   public int Load_No { get; set; }

   public string CustomerName { get; set; }

   public int LoanAmount { get; set; }

   public double EMI_Amount { get; set; }

   public int AccountBalance { get; set; }

   public void Calculate_EMI()
   {
      // reducing-balance method A = P * (r*(r+1)^n)/((1+r)^n - 1)
      // where P = principal borrowed(load amount)
      // r = periodic interest (annual interest rate / 1200)
      // n = total number of payment (number of month)

      var periodicInterestRate = INTEREST_RATE / 1200; // periodic interest rate
      var monthCount = YEARS_COUNT * 12; // common month count

      EMI_Amount = LoanAmount * (
         (periodicInterestRate * Math.Pow((1 + periodicInterestRate), monthCount))
            / (Math.Pow((1 + periodicInterestRate), monthCount) - 1)); 
   }

   public void CheckBalance()
   {
      if (AccountBalance < EMI_Amount)
      {
         throw new Exception("Not Sufficient Balance to repay Loan");
      }
   }
}

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