### Need Help with this simple math problem

I have a formula.

PV=FV/(1+r)^n

Fv = \$250.00

the letter r is rates in percentages.
so 5 % is 0.05

n is the number of years. my number is 4

so on s calculator 250.00/(1+0.005)^4= 205.675618698

Here is what I have in c++ code

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182`` `````` #include #include #include using namespace std; int main(int argc, char *argv()) { float pv, fv, r=0; int n=0; char answer = 0; int mainloop = 1; int firstloop = 1; while(firstloop> 0){ cout <<"Welcome. "<>answer; if (answer == 'e'|| answer == 'E') { cout<<"Good bye"< 0) { system("CLS"); cout<<"Enter the cost value FU:"<>fv; cout<>r; cout<<"Enter the number of years:"; cin>>n; r/100; for(n;n>0;n-- ) { pv = pow(fv/(1+r),n); cout<
Last edited on
This `pow(fv/(1+r),n);` doesn't look the same as 250.00/(1+0.05)^4
instead, it is calculating (250.00/(1+0.05) ) ^4
I figure it out. Sorry I posted too soon. Here is my working program

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475`` ``````#include #include #include using namespace std; int main(int argc, char *argv()) { float pv=0, fv=0, r=0, vp; int n=0; char answer = 0; int mainloop = 1; int firstloop = 1; while(firstloop> 0){ cout <<"Welcome. "<>answer; if (answer == 'e'|| answer == 'E') { cout<<"Good bye"< 0) { system("CLS"); cout<<"Enter the cost value FV:"<>fv; cout<>r; cout<<"Enter the number of years:"; cin>>n; r=r/100; for(n;n>0;n-- ) { pv=pow((1.0+r),n); vp = (fv/pv); cout<

If you enter 250.00 as your dollar value, and 5 as your rates, number of years being 4
205.675 will appear as one of the answers along with th
Topic archived. No new replies allowed.