Assignment:
"In this assignment, you are to write a program that will compute a monthly payment. You are to have, at least, 1 function ( other than main() ) in your program."
http://www.comsc.uco...se-payment.html
Problem:
I keep getting "inf" when I run the program. I mean, it's obvious that the main function is okay since it does ask for the input and displays something, so there must be a problem with the calculation function, but I'm not sure what the problem is.
#include <iostream>
#include <math.h>
using namespace std;
float calculation(float p, float yir, float y)
{
float mir, payment, a, b, c, d, e, f;
mir = yir / 1200;
a = 1 + mir;
b = 1 / a;
c = 12 * y;
d = pow(b, c);
e = 1 - d;
f = p * mir;
payment = f / e;
return payment;
}
int main()
{
float p, yir, y, x;
x = calculation(p, yir, y);
cout << "Input principal amount" << endl;
cin >> p;
cout << "Input yearly interest rate" << endl;
cin >> yir;
cout << "Input term in years" << endl;
cin >> y;
cout << x << endl;
}
Any help would be grateful.

New Topic/Question
Reply



MultiQuote






|