Click to See Complete Forum and Search --> : Monthly payment and interest


Fatal510
February 28th, 2008, 06:11 AM
// payments.cpp : main project file.

#include "stdafx.h"
#include "cmath"
#include "iostream"


using namespace System;


int main(array<System::String ^> ^args)
{ float PaymentO, RateInt = 0, BalK = 0;
int NumPay = 0, pmt = 0, k = 0;


std::cout << "Enter payment amount: ";
std::cin >> PaymentO;

std::cout << "Enter Annual interest rate (9% as 0.09) : ";
std::cin >> RateInt;

std::cout << "Enter number of payments: ";
std::cin >> NumPay;

k = 1;

RateInt = RateInt / 12;
float x = pow(1 - ( 1 + RateInt ),k - NumPay);

BalK = PaymentO * (x / RateInt);


std::cout << "Payment entered was : " << NumPay
<< "\nInterest rate is " << RateInt << " percent per month"
<< "\nPayment #1 leaves a balance of $" << BalK;



std::cout << "\nHit enter to close... ";
std::cin >> PaymentO;
return 0;
}




something is going wrong with the formula that i tried to code the output is giving me "-1.#INF". i have tried everything i can think of.


RateInt = RateInt / 12;
float x = pow(1 - ( 1 + RateInt ),k - NumPay);

BalK = PaymentO * (x / RateInt);


i input:

Enter payment amount: 136.35

Enter Annual interest rate (9% as 0.09) : 0.09

Enter number of payments: 36

and get "-1.#INF" when i should be getting

Payment entered was : $165.35
Interest rate is 0.09 percent which is 0.0075 percent per month
Number of payments is 36
Payment #1 leaves a balance of $5073.38





I've included the formatted formula as if you were to write it on paper in the word document attached.