int GetData (int* PR, int* IY, int* NY);
double monthly_payment (double MP, int PR, double IM, double Q);
void print_amortization_table (int PR, int IY, double IM, int NY, int NM, double MP);
int main (void)
{
int NY; //number of years
int NM; //number of months
int IY; //interest/year
int PR; //principle
double P; //value of (1+IM)^NM
double X; //value of (1+IM)
double Q; //value of (p/(p-1))
double IM; //interest/month
double MP; //monthly payment
GetData (&PR, &IY, &NY); //call to GetData
IM = (IY / 12) / 100; //calculations
X = (1 + IM);
NM = (NY * 12);
P = pow(X, NM);
Q = (P / (P-1));
MP = (PR * IM * Q); //TEMP--- TO BE REMOVED
printf("NY NM IY PR IM MP\n"); //TEMP--- TO BE REMOVED
printf("%d %d %d %d %lf %lf\n", NY, NM, IY, PR, IM, MP); //TEMP--- TO BE REMOVED
//monthly_payment (MP, PR, IM, Q); call to monthly payment
//print_amortization_table (PR, IY, IM, NY, NM, MP); call to print_amortization_table
}
int GetData (int* PR, int* IY, int* NY)
{
printf("Amount of the loan (Principle)? ");
scanf("%d", &PR);
printf("Interest rate / year (percent)? ");
scanf("%d", &IY);
printf("Number of years? ");
scanf("%d", &NY);
}
答案 0 :(得分:3)
由于你已经将地址作为参数传递给函数GetData,所以你需要替换你的函数:
int GetData (int* PR, int* IY, int* NY)
{
printf("Amount of the loan (Principle)? ");
scanf("%d", PR); //PR is the address already
printf("Interest rate / year (percent)? ");
scanf("%d", IY); //IY is the address already
printf("Number of years? ");
scanf("%d", NY); //NY is the address already
}