Hi, I'm writing this program and it says "Error: cannot convert 'double(*)(double,double)' to 'double' for argument '3' to 'double futureSal (int, double, double)'". Can anyone give me some advice?
#include <iostream>
#include <cmath>
usingnamespace std;
double hikerate (double thisSal, double lastSal);
double futureSal (int year, double thisSal, double hikerate);
int main()
{
double thisSal, lastSal;
int year;
char ans;
do
{
cout << "Input the annual salary of this year and last year." << endl;
cin >> thisSal >> lastSal;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "The rate of raise is " << hikerate (thisSal,lastSal) << "%" << endl;
cout << "Input the number of years wanna forecast." << endl;
cin >> year;
cout << "The salary of " << year << " year(s) later is " << futureSal (year, thisSal, hikerate)<< endl;
cout << "Wanna gauge again? ";
cin >> ans;
}
while (ans=='y'||ans=='Y');
return 0;
}
double hikerate(double thisSal, double lastSal)
{
return ((thisSal-lastSal)*100/lastSal);
}
double futureSal (int year, double thisSal, double hikerate)
{
double rate;
rate = (1+hikerate/100);
return (thisSal*(pow(rate,year)));
}
The function hikerate is the rate of salary increment, which has 2 argument thisSal and lastSal. hikerate itself is also an argument of function futureSal.
// cout << "The salary of " << year << " year(s) later is " << futureSal (year, thisSal, hikerate)<< endl;
cout << "The salary of " << year << " year(s) later is " << futureSal (year, thisSal, hikerate(thisSal,lastSal) ) << endl;