Question #44699

Dwayne often needs to calculate the amount of Emulated Monthly Installment (EMI) that needs to be charged from a particular person. The EMI is calculated according to the following formula:

EMI = Principal loan amount×Rate of interest×(1 + Rate of interest)Tenure of loan in months/((1 + Rate of interest)Tenure of loan in months - 1)

The rate of interest is calculated on a monthly basis. For example, if the rate of interest is 12 % per annum, it is calculated as (12/100)/12.

Dwayne manually calculates the interest rate using a calculator. However, he often commits mistakes in calculating the interest due to the complex formula. Therefore, he asks Elina to build an application that accepts the principal loan amount, rate of interest, and tenure of the loan and calculates the EMI amount. Write the code that Elina should implement to create the application.
1

Expert's answer

2014-08-07T04:07:11-0400

Here is the processed document with the code block restored and formatted:

Answer on Question #44699, Programming, C#

Problem.

Dwayne often needs to calculate the amount of Emulated Monthly Installment (EMI) that needs to be charged from a particular person. The EMI is calculated according to the following formula:


EMI=Principal loan amountRate of interest×(1+Rate of interest)×(Tenure of loan in months/((1+Rate of interest)×Tenure of loan in months1))\text{EMI} = \frac{\text{Principal loan amount}}{\text{Rate of interest}} \times (1 + \text{Rate of interest}) \times (\text{Tenure of loan in months} / ((1 + \text{Rate of interest}) \times \text{Tenure of loan in months} - 1))


The rate of interest is calculated on a monthly basis. For example, if the rate of interest is 12%12\% per annum, it is calculated as (12/100)/12(12/100)/12.

Dwayne manually calculates the interest rate using a calculator. However, he often commits mistakes in calculating the interest due to the complex formula. Therefore, he asks Elina to build an application that accepts the principal loan amount, rate of interest, and tenure of the loan and calculates the EMI amount. Write the code that Elina should implement to create the application.

Solution.

Code

using System;
class Program
{
    static void Main()
    {
        float loanAmount; // Principal loan amount
        float interest; // Rate of interest
        float tenureAmount; // Tenure of loan in months
        float EMI;
        // Input
        Console.Write("Principal loan amount: ");
        loanAmount = float.Parse(Console.ReadLine());
        Console.Write("Rate of interest per month: ");
        interest = float.Parse(Console.ReadLine());
        Console.Write("Tenure of the loan amount: ");
        tenureAmount = float.Parse(Console.ReadLine());
        // EMI formula
        interest = interest / 100;
        EMI = (float)(loanAmount * interest * (1 + interest) * tenureAmount) /
              ((1 + interest) * tenureAmount - 1);
        // Output
        Console.WriteLine(String.Format("EMI equals: {0:F3}", EMI));
    }
}

Result

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!
LATEST TUTORIALS
APPROVED BY CLIENTS