I'm currently working on my classwork and these two errors keep on popping up. What am I doing wrong this time?
1>c:\users\andy\documents\visual studio 2010\projects\assign2\assign2\assign2.cpp(57): error C2660: 'maturity' : function does not take 1 arguments
1>c:\users\andy\documents\visual studio 2010\projects\assign2\assign2\assign2.cpp(100): error C2660: 'maturityDriver' : function does not take 0 arguments
// "Maturity Value/Loan Payment Calculation"
// Programmer's Name: Andy
// Date: September 15, 2011
// Class: Computer Science 175
// Briefing:
// This program can calculate the Maturity value of an investment or
// the Monthly Payments on a loan. The program asks the user to select
// which calculation they want to perform. If the user selects Maturity,
// then it calls the Maturity Value function. If the user selects
// Loan Payment calculation, then it calls the Loan Payment function.
#include "stdio.h"
#include <iostream>
#include <math.h>
usingnamespace std;
double maturity (double invest, float interest, float duration, float conversion)
{
cout << "This program will calculate the Maturity value of an investment." << endl << endl;
cout << "Please enter the Investment Amount" << endl;
cin >> invest;
cout << "Please enter the Interest" << endl;
cin >> interest;
cout << "Please enter the Number of Years" << endl;
cin >> duration;
cout << "Please enter the Conversions/Year" << endl;
cin >> conversion;
interest = (interest/100);
float togotomypower;
togotomypower = (1+(interest/conversion));
float mypower;
mypower = (duration*conversion);
double result;
result = (invest*pow(togotomypower,mypower));
return result;
}
int maturityDriver(double result)
{
maturity(result);
cout << "Maturity value of your investment: " << "$" << result << endl;
system("pause");
return 0;
}
double loan (double amount, float interest, float duration)
{
interest = interest/1200;
float temp;
temp = (1+interest);
float temp2;
temp2 = pow(temp,duration);
float top;
top = interest*temp2;
float bottom;
bottom = temp2 - 1;
double result;
result = (top/bottom)*amount;
return result;
}
int loanDriver()
{
system("pause");
return 0;
}
int main(void)
{
cout << "This program can calculate the Maturity value of an investment or ";
cout << "the monthly payments on a loan." << endl;
cout << " 1) Maturity Calculation" << endl;
cout << " 2) Monthly Payments" << endl;
cout << "Please press 1 or 2: ";
char response = ' ';
cin >> response;
if (response == '1')
{
maturityDriver();
}
elseif (response == '2')
{
loanDriver();
}
else
{ cout << "You entered in an invalid option." << endl;
}
system("pause");
return 0;
}
The errors are telling you that you're invoking maturityDriver( ) and maturity( ) without passing the arguments they require.
maturityDriver() and maturity( ) require arguments in order for the execution to begin. If you don't want to pass arguments, you can provide default values for each argument. This can be done by using the assignment operator. For example:
You can do this with maturityDriver( ) too. Now, with the default values in place, you can invoke both functions without passing arguments. If you don't pass arguments, the function will use the default values you provided.
Also, since both maturity( ) and maturityDriver( ) return values, you should store them in a local or global variable.