### Having Problems... Help?

I have to write a program that tells the user how much they should deposit into a savings account if they want to obtain a certain amount over a period of time. This is the formula given:

P = F / (1 + r)^n

P is the present value that is depositted.
F is the future value that the user wants to obtain.
r is the annual interest rate.
n (which is an exponent in the formula) is the number of years that the money sits in the account.

You should be able to enter all the information and the program will calculate and tell the user how much they should deposit (present value). Here is what I have so far:

 ``12345678910111213141516171819202122232425262728293031323334353637`` ``````#include #include using namespace std; double interestRate(double annualInterest) { return 1 + annualInterest; } double years(double numberYears) { return pow(interestRate, numberYears); } double presentValue(double futureValue, double years) { return futureValue / years; } int main() { double future; cout << "What is the future value you wish to have?" << endl; cin >> future; double rate; cout << "What is the annual interest rate?" << endl; cin >> rate; double year; cout << "How many years do you want to save?" << endl; cin >> year; cout << "The amount you should deposit today is: \$" << presentValue << endl; return 0; }``````

Can someone help me out with what's wrong please?
For starters the variable presentValue does not exist. It doesn't look like you made much of an effort.
What do you mean it doesn't exist? I thought I initialized it at the top along with the formula?
Topic archived. No new replies allowed.