EMI Calculator using Web Service
1) Go To Visual Studio 2010 -> New Project -> Select Asp.NET Web Service Application -> OK
2) In Service1.asmx.cs write the following code and Run the Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace EMI_Calculator
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public double EMI_Calculator(double LoanAmount, int PeriodInMonths, double InterestRate)
{
// E = P×r×(1 + r)n/((1 + r)n - 1)//
// r is rate of interest calualted in monthly basis it should be = Rate of Annual interest/12/100
double AnnualInterest = InterestRate / 12 / 100;
double EmiAmount = LoanAmount * AnnualInterest * (Math.Pow((1 + AnnualInterest), PeriodInMonths)) / ((Math.Pow((1 + AnnualInterest), PeriodInMonths) - 1));
return Math.Round(EmiAmount / InterestRate);
}
}
}
3) Click on "EMI Calculator" Service to invoke
4) pass the parameters Loan Amount,Period in Months,Interest rate
5)EMI Amount is displayed