求高手指点
float calculateMonthlypayment(float* IM,float* PP, float* NB){
float rateM;
float MP,PR;
*IM=PR*rateM; //月利息=本金*月利息
*PP=MP-IM ; //月还本金=月还总额-月利息
*NB=PR-PP; //新本金=本金-月还本金
return 0;
}
以上是错误的地方,我不知道咋改,
以下是原函数
#include<stdio.h>
#include<math.h>
float printInformation(float PR,float rateY,float MP);
float calculateMonthlypayment(float*IM,float* PP, float* NB);
float printAmortizationTable(float NB,float PR,float IM,float PP);
int main()
{
float PR,MP,IM,NB,PP,rateY; //PR是本金,MP是每月要还的钱,IM是每月要还的利息,PP是要还的本金,rateY是年利率;
printInformation( PR,rateY,MP);
calculateMonthlypayment(&IM,&PP,&NB);
printAmortizationTable(NB,PR,IM, PP);
return 0;
}
float printInformation(float PR,float rateY,float MP)
{
int Y,M; //Y;年。M;月;
float rateM; //rateM是月利率;
printf("the amont of the loan(principal); ");
scanf("%f",&PR);
printf("interest rate/year (percent); ");
scanf("%f",&rateY);
printf("interest rate/month (decimal); ");
scanf("%lf",&rateM);
printf("number of years; ");
scanf("%d",&Y);
printf("number of month; ");
scanf("%d",&M);
printf("monthly payment; ");
scanf("%f", &MP);
return 0;
}
float calculateMonthlypayment(float* IM,float* PP, float* NB)
{
float rateM;
float MP,PR;
*IM=PR*rateM; //月利息=本金*月利息
*PP=MP-IM ; //月还本金=月还总额-月利息
*NB=PR-PP; //新本金=本金-月还本金
return 0;
}
float printAmoitizationTable(float PR,float PP,float NB)
{
int M;
float IM,MP;
float sum=0.00;
printf(" old month Interest principal new\n");
printf("month\n");
printf(" Balanxe payment paid paid balance\n");
for(M=1;M<=12;M++)
{
printf("%d %f %f %f %f %f ",M,PR,MP,IM,PP,NB);
PR=NB;
sum=sum+PP;
}
printf("total amount paid; %f",&sum);
}