我被告知要建立一个名为comparison()的函数来比较两个财务计划。 这两个财务计划在他们自己的职能部门中完美运作。 如何调用compare()函数中的两个函数?
这是第一份财务计划的代码。
void oneLumpSumWithdrawal( int startingAge, int numOfYears,
double lumpSumAmount, double interestRate )
{
int age = startingAge;
int lastAge = startingAge + numOfYears;
double cash = lumpSumAmount;
cout << "Age | oneLumpSum" << endl;
cout << "----+----------------" << endl;
while (age <= lastAge)
cout.width(3);
cout << age << " | ";
cout.width(15);
cout.precision(2);
cout.setf(ios::fixed);
cout << cash << endl;
if (age != lastAge)
cash = cash + cash*interestRate / 100.0;
age++;
system("pause");
}
这是第二个财务计划的代码
void yearlyWithdrawal(int startingAge, int numOfYears, int yearlyAmount, double interestRate)
{
int age = startingAge;
int lastAge = startingAge + numOfYears;
double cash = yearlyAmount;
cout << "Age | Yearly Plan" << endl;
cout << "----+----------------" << endl;
while (age <= lastAge)
{
cout.width(3);
cout << age << " | ";
cout.width(15);
cout.precision(2);
cout.setf(ios::fixed);
cout << cash << endl;
if (age != lastAge)
{
cash = (cash + cash*interestRate / 100.0) + yearlyAmount;
age++;
}
}
system("pause");
}
我试着这样称呼它,但它没有用。
void comparison()
{
oneLumpSumWithdrawal( startingAge, numOfYears,
lumpSumAmount, interestRate );
yearlyWithdrawal(int startingAge, int numOfYears, int yearlyAmount, double interestRate);
}
用户将在main函数内的switch语句中调用该函数。
答案 0 :(得分:0)
您正在致电
yearlyWithdrawal(int startingAge, int numOfYears, int yearlyAmount, double interestRate);
但是在调用函数时不必包含类型。你必须致电
yearlyWithdrawal( startingAge, numOfYears, yearlyAmount, interestRate);