I am doing this program and I have to use the Pmt function... and I cannot get it to work.. thing is I have to calculate the principal and interest and I have to assume that the term of the loan is 30 years or 360 months..... I have an input interest rate of 0.07 and a purchase price of 95000. I have this code but it keeps giving me the wrong answer...Can anyone help me? I do not know if I am usning the function as I should.. Any help would be nice.. Thnanks in advance.

I have to enter the purchase price and interest rate:

mdblInterestRate = Convert.ToDouble(txtInterestRate.Text) / 12
mdblPurchasePrice = Convert.ToDouble(txtPurchasePrice.Text)
mdblTermMonth = Convert.ToInt32(mdblTermMonth)

mdblPrinAndInterest = Convert.ToDouble(Pmt(mdblInterestRate,mdblTermMonth, mdblPurchasePrice))
mdblPrinAndInterest = System.Math.Abs(mdblPrinAndInterest)
txtPrinAndInterest.Text = mdblPrinAndInterest.ToString("c")

The answer should be 505.63 but i am getting 632.04

• : I am doing this program and I have to use the Pmt function... and I cannot get it to work.. thing is I have to calculate the principal and interest and I have to assume that the term of the loan is 30 years or 360 months..... I have an input interest rate of 0.07 and a purchase price of 95000. I have this code but it keeps giving me the wrong answer...Can anyone help me? I do not know if I am usning the function as I should.. Any help would be nice.. Thnanks in advance.
:
: I have to enter the purchase price and interest rate:
:
: mdblInterestRate = Convert.ToDouble(txtInterestRate.Text) / 12
: mdblPurchasePrice = Convert.ToDouble(txtPurchasePrice.Text)
: mdblTermMonth = Convert.ToInt32(mdblTermMonth)
:
: mdblPrinAndInterest = Convert.ToDouble(Pmt(mdblInterestRate,mdblTermMonth, mdblPurchasePrice))
: mdblPrinAndInterest = System.Math.Abs(mdblPrinAndInterest)
: txtPrinAndInterest.Text = mdblPrinAndInterest.ToString("c")
:
: The answer should be 505.63 but i am getting 632.04
:

try rounding your doubles with the format function to however many decimal places and then using CDbl to convert it back... )

• : I am doing this program and I have to use the Pmt function... and I cannot get it to work.. thing is I have to calculate the principal and interest and I have to assume that the term of the loan is 30 years or 360 months..... I have an input interest rate of 0.07 and a purchase price of 95000. I have this code but it keeps giving me the wrong answer...Can anyone help me? I do not know if I am usning the function as I should.. Any help would be nice.. Thnanks in advance.
:
: I have to enter the purchase price and interest rate:
:
: mdblInterestRate = Convert.ToDouble(txtInterestRate.Text) / 12
: mdblPurchasePrice = Convert.ToDouble(txtPurchasePrice.Text)
: mdblTermMonth = Convert.ToInt32(mdblTermMonth)
:
: mdblPrinAndInterest = Convert.ToDouble(Pmt(mdblInterestRate,mdblTermMonth, mdblPurchasePrice))
: mdblPrinAndInterest = System.Math.Abs(mdblPrinAndInterest)
: txtPrinAndInterest.Text = mdblPrinAndInterest.ToString("c")
:
: The answer should be 505.63 but i am getting 632.04
:

to get 505.634947746044
interest rate would have to be .04925
for 95000 on 360 monthly payments

Dim mdblInterestRate As Double
Dim mdblPurchasePrice As Double
Dim mdblTermMonth As Double
Dim mdblPrinAndInterest As Double
mdblTermMonth = 12 * 30

mdblInterestRate = CDbl(txtInterestRate.Text) / 12
mdblPurchasePrice = 0 - CDbl(txtPurchasePrice.Text)
mdblPrinAndInterest = Pmt(mdblInterestRate, mdblTermMonth, mdblPurchasePrice, 0, DueDate.EndOfPeriod)

mdblPrinAndInterest = System.Math.Abs(mdblPrinAndInterest)

Debug.WriteLine("Interest Rate = " & mdblInterestRate.ToString)
Debug.WriteLine("Purchase Price = " & mdblPurchasePrice.ToString)
Debug.WriteLine("Principle + Interest = " & mdblPrinAndInterest.ToString)