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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <cmath>
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.