future value formula

I am a complete beginner so I'm not sure if I'm doing this right. My code keeps giving me 0.00 as an answer so my formula is probably the problem. Please help.

[note: presentValue is what I'm solving for, everything else the user inputs]

FORMULA: P = F/(1+r)^n

#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int main()

{
double presentValue;
int futureValue;
int interestRate;
int numberOfYears;


cout<<"Enter the number of years: "<<endl;
cin>>numberOfYears;
cout<<"Enter your future value: "<<endl;
cin>>futureValue;
cout<<"Enter your rate(as decimal): "<<endl;
cin>>interestRate;
presentValue = (futureValue / pow((1+interestRate),numberOfYears));
cout<<"\n";
cout<<fixed<<showpoint<<setprecision(2);
cout<<"Your present value is: " <<presentValue<<endl;



system("PAUSE");

return 0;

}
Last edited on
Topic archived. No new replies allowed.