Oct 11, 2017 at 8:50pm UTC
#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;
}
Oct 11, 2017 at 9:57pm UTC
You failed to put it between code tags. :)
Oct 11, 2017 at 10:16pm UTC
Secondly what is your code supposed to do?
Talemache~
Oct 12, 2017 at 1:54am UTC
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