line 76 41 [Error] cannot convert 'float (*)(float, int)' to 'float' for argument '2' to 'float compound2y(int, float, double, int)'
line 77 43 [Error] cannot convert 'float (*)(float, int)' to 'float' for argument '2' to 'float compound10y(int, float, double, int)'
#include <iomanip>//needed for cout, cin and endl
#include <iostream>//needed to set width and precision
#include <cmath>//needed for math function
#include <windows.h>//needed for text and background colour changes
#include <string>
using namespace std;//avoids using std with cin, cout, endl etc.
float calc(float r, int n);
float compound2y(int p, float calc, double x, int initialdeposit);
float compound10y(int p, float calc, double y, int initialdeposit);
int main (int arc, char* argv[] )
{
system("COLOR F0"); //inverts colours, white background, black text
cout << "\nDo you want to try another interval? (Y/N) ";
cin >> ans;
if (ans == 'N' || ans == 'n')//condition if user answers no to question
{
cin.get();//end program
}
else if (ans != 'Y' && ans !='y' && ans != 'N' && ans != 'n')//condition if user enters a character
//that is not Y or N. Else if because if condition already used to end
//program if user answers no, and do while loop condition for user
//answers yes.
{
//display error message if user enters an invalid character
SetConsoleTextAttribute(hConsole,244);//changes error message text
//to red.
cout << "\nInvalid input. Please answer Y / N. ";//error message.
//request new input.
SetConsoleTextAttribute(hConsole,240);//changes answer text to black
cin >> ans;//new answer
}
}
while ((ans == 'Y') || (ans == 'y') && (initialdeposit<=max));
//allow user to see result before ending
cout << "\n\nPress enter to end this program" << std::endl;
cin.get();
}