#include<stdio.h>
#include <stdlib.h>
#include<math.h>
double futurelnvestmentValue(double investmentAmount,double monthlyInterestRate,int years);
int main()
{
double investmentAmount,yearlyInterestRate,years,monthlyInterestRate;
scanf("%lf,%lf,%lf",&investmentAmount,&yearlyInterestRate,&years);
for(years=1;years<=6;years++)
{
printf("%d\n",futurelnvestmentValue);
}
return 0;
}
double futurelnvestmentValue(double investmentAmount,double monthlyInterestRate,int years)
{
int yearlyInterestRate;
monthlyInterestRate=yearlyInterestRate/12;
futurelnvestmentValue=investmentAmountpow((1+monthlyInterestRate),(years12));
return futurelnvestmentValue;
}
编码哪里错了
若函数futureInvestmentValue( )用于计算投资的未来投资值,并且它的函数原型如下:double futurelnvestmentValue(double investmentAmount,
double monthlyInterestRate, int years);
●investmentAmount
投资额
monthlyInterestRate
月利率
●year
投资年限
, 未来投资额=投资额x(1 +月利率)年数x12
语法错误见注释处,未来投资额=投资额x(1 +月利率)年数x12 公式不全?逻辑错误因题目不全,未修改,供参考:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double futurelnvestmentValue(double investmentAmount,double monthlyInterestRate,int years);
int main()
{
double investmentAmount,yearlyInterestRate,years,monthlyInterestRate;
scanf("%lf,%lf,%lf",&investmentAmount,&yearlyInterestRate,&years);
for(years=1;years<=6;years++) //???
{
printf("%d\n",futurelnvestmentValue(investmentAmount,yearlyInterestRate,years));
//printf("%d\n",futurelnvestmentValue);
}
system("pause");
return 0;
}
double futurelnvestmentValue(double investmentAmount,double monthlyInterestRate,int years)
{
double yearlyInterestRate;
//int yearlyInterestRate;
//monthlyInterestRate = yearlyInterestRate/12;
yearlyInterestRate = investmentAmount * (1+monthlyInterestRate) * (years) * 12;
//未来投资额=投资额x(1 +月利率)年数x12 公式不全?
//futurelnvestmentValue=investmentAmount*pow((1+monthlyInterestRate),(years12));
return yearlyInterestRate;
//return futurelnvestmentValue;
}