have code but trying to figure out what i did wrong

#include<iostream>
#include <iomanip>
#include<cmath>
using namespace std;

double calculatePresentValue(double futureValue, double interestRate, double numberYears)
{

double resultInterest;
double presentVal;

resultInterest = interestRate/100;
presentVal = futureValue /(1+ pow(resultInterest,numberYears));
cout << "Present Value: " << presentVal;
return presentVal;
}

double futureValue()
{
double futureVal;

cout << "Future value: ";
cin >> futureVal;
if (futureVal <= 0)
{
cout << "The future value must be greater than zero\n";
}
return futureVal;
}
double annualInterestRate()
{
double annualInterest;

cout << "Annual interest rate: ";
cin >> annualInterest;

if (annualInterest <= 0)
{
cout << "The annual interest rate must be greater than zero\n";
}
return annualInterest;
}
int numOfYears()
{
int years;

cout << "Years: ";
cin >> years;
if(years < 0)
{
cout << "The number of years must be greater than zero\n";
}
return years;
}


int main()
{
cout << "Enter future value\n";
cout << "Enter annual interest rate\n";
cout << "Enter number of years\n";
{
futureValue();
annualInterestRate();
numOfYears();
calculatePresentValue(futureValue, annualInterestRate, numOfYears);

}



return 0;
}

You failed to put it between code tags. :)
Lol, I got you:

Talemache~

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

#include<iostream>
#include <iomanip>
#include<cmath>
using namespace std;

double calculatePresentValue(double futureValue, double interestRate, double numberYears)
{

double resultInterest;
double presentVal;

resultInterest = interestRate/100;
presentVal = futureValue /(1+ pow(resultInterest,numberYears));
cout << "Present Value: " << presentVal;
return presentVal;
}

double futureValue()
{
double futureVal;

cout << "Future value: ";
cin >> futureVal;
if (futureVal <= 0)
{
cout << "The future value must be greater than zero\n";
}
return futureVal;
}
double annualInterestRate()
{
double annualInterest;

cout << "Annual interest rate: ";
cin >> annualInterest;

if (annualInterest <= 0)
{
cout << "The annual interest rate must be greater than zero\n";
}
return annualInterest;
}
int numOfYears()
{
int years;

cout << "Years: ";
cin >> years;
if(years < 0)
{
cout << "The number of years must be greater than zero\n";
}
return years;
}


int main()
{
cout << "Enter future value\n";
cout << "Enter annual interest rate\n";
cout << "Enter number of years\n";
{
futureValue();
annualInterestRate();
numOfYears();
calculatePresentValue(futureValue, annualInterestRate, numOfYears);

}



return 0;
}
Secondly what is your code supposed to do?

Talemache~
Its supposed to calculate present value with multiple functions. Although its given me the error of " error: cannot convert ‘double (*)()’ to ‘double’ for argument ‘1’ to ‘double" and I'm not sure what i did wrong
Topic archived. No new replies allowed.