### 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~

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475`` `````` #include #include #include 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.