I need to compute monthly payment (M) for an installment loan given the loan amount (P), period (in years), and the annual percentage rate. M = (P * i * (1 + i)n) / ((1 + i)n – 1) where i = annual percentage rate / 1200 and n = period * 12.
I need to do this using a web service on visual studio. I can’t seem to use the Math.Pow in a web service. this is my Code in the method:
This is my error message: Error 1 ‘ProjectFive.payment.Math(double, double, double, double)’ is a ‘method’, which is not valid in the given context c:\users\parodeghero\documents\visual studio 2010\Projects\ProjectFive\ProjectFive\payment.asmx.cs 27 38 ProjectFive
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace ProjectFive
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class payment : System.Web.Services.WebService
{
[System.Web.Services.WebMethod()]
public double Math(double loan, double rate, double period, double payment)
{
rate = rate / 100;
period = period * 12;
payment = loan*(rate/1200)*Math.Pow((1+(rate/1200)), period)/ Math.Pow((1 + (rate/1200)), period) - 1;
return payment;
}
}
}
Rename your method, you can’t call it Math !