Reputation: 335
I'm having issue with my code, in that I can't figure out why I'm receiving an error. Here is the code:
using namespace std;
void presentValue();
bool stringChar();
bool stringVal();
double futureValConv();
int main()
{
cout << "Welcome to the Present Value Interest Calculator!\n\"First, let me collect some data." << endl << endl;
presentValue();
return 0;
}
void presentValue()
{
//declare variables
//Response value intialized as x for debugging
char response = 'x';
while (response != 'n' || response != 'N')
{
//declare variables
double intRate = 0;
string futureValString;
double futureVal;
double years = 0;
//Simple present value equation
double presentVal = futureVal / pow((intRate + 1), years);
cout << "What's your Interest Rate? ";
cin >> intRate;
cout << "OK, and what's your desired Future Value? [H}elp ";
cin >> futureVal;
//Run descending help program that won't allow escape without a double value
**futureVal = futureValConv(futureValString);**
cout << endl << endl << "And finally, how many years would you like to save your money for? ";
cin >> years;
cout << endl << "You've made it this far!!!";
cout << endl << endl << presentVal;
}
}
inline double futureValConv(string somestring)
{
//delcare variables
double newString = 0;
**if (stringChar(somestring))**
{
cout << endl << "Future Value is the amount you would like to have in your account in the future.\n\n";
cout << "How much might that be? ";
cin >> somestring;
futureValConv(somestring);
}
**else if(stringVal(somestring))**
{
//Convert the Future Value String to a double for future use
newString = atoi(somestring.c_str());
}
else
{
cout << "Please enter a proper value. ";
futureValConv(somestring);
}
return newString;
}
bool stringChar(string response)
{
//declare variables
char answer = response[0];
bool status = false;
if (answer == 'H' || answer == 'h')
{
status = true;
return status;
}
}
bool stringVal(string response)
{
//declare varialbes
int answer = atoi(response.c_str());
bool status = false;
int powZero = (answer, 0);
if (powZero == 1)
{
status = true;
return status;
}
}
I posted most of my code because I can't grasp what is going on here. It is telling me that stringChar and stringVal do not take 1 arguments, as well as futureValConv. I am attempting to run a function checking the value of a string, and determining what the value is before making a decision. In two of the three instances, the function calls itself to run again until the user has entered an acceptable double (Which I check by running to the power of 0 for a an answer of 1.) I have bolded the three lines generating an error. Interestingly, even by commenting out the function futureValConv and never calling into the other functions, I still get two of the three errors.
Upvotes: 3
Views: 20445
Reputation: 4092
You declared this at the top:
bool stringChar();
bool stringVal();
So the compiler expects stringChar and stringVal functions to have no arguments. Change the declaration to:
bool stringChar(string response);
bool stringVal(string response);
Upvotes: 1