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:
The rate of interest is calculated on a monthly basis. For example, if the rate of interest is per annum, it is calculated as .
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
Comments