我一直收到相同的错误消息,不知道如何纠正
/*This program will prospective borrowers calculate monthly payment on a loan.
The program also prints the amortization table to show the balance of the loan after each monthly payment.
By: Kenneth Moore
Date: 3/13/2016
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>>
const float monthInYear = 12; //This is a constant for the number of months in a year
const float percentTotal = 100; //This is a constant for calculating percentages
void getData (float* prPtr, float* nyPtr, float* iyPtr);
//this function will calculate the data for monthly payments based off APR and return the data to be printed on a table
float calculateMonthlyPayment (float* nmPtr, float* imPtr, float* pPtr, float* qPtr, float* mpPtr, float* nyPtr, float* iyPtr, float* prPtr);
//This function will print the data
void printInformation ();
//This function will display information in a table format
void printAmortizationTable ();
int main()
{
float nm; //scheduled number of months for the loan
float ny; //scheduled number of years to amortize the loan
float iy; //interest rate per year as a percentage
float im; //interest rate/month decimal
float pr; //principal the amount of the loan
float p; //the value of (1+IM)
float q; //the value of P/(P-1)
float mp; //Monthly payment
printf("Welcome the following program will help you decide how much loan you can afford.");
printf("You will be prompted to enter the principle amount of the loan, the interest");
printf("rate, and the length of the loan in years. It will then show you on a table");
printf("how much your monthly payment will be and how much of the loan remains after");
printf("each payment.");
getData (&pr, &ny, &iy);
calculateMonthlyPayment(&nm, &im, &p, &q, &mp, &ny, &iy, &pr);
return 0;
}
/*This function is a data collecting function the will collect user imputed data about the loan and calculate the interest and
payments to be printed in later functions*/
//Statement
void getData (float* prPtr, float* nyPtr, float* iyPtr)
{
printf("\nEnter the amount of money you wish to borrow.");
scanf("%f", prPtr);
printf("Enter the length in years for the loan.");
scanf("%f", nyPtr);
printf("Enter your expected interest rate.");
scanf("%f", iyPtr);
return;
}
//This function will now process the data to return the payment amount to be used in the table
float calculateMonthlyPayment (float* nmPtr, float* imPtr, float* pPtr, float* qPtr, float* mpPtr, float* nyPtr, float* iyPtr, float* prPtr)
{
nmPtr =(nyPtr*12); //how many months the loan will be in effect
imPtr =(iyPtr/monthInYear)/percentTotal; //how much interest is paid per month
//this is my error location how can i reslove it
pPtr = pow(1+imPtr,nmPtr);
qPtr = pPtr/(pPtr-1);
mpPtr = (prPtr*imPtr*qPtr);
}
答案 0 :(得分:0)
你是一个带常数的指针。我想你想要指针所指向的值。使用指针 - 解引用运算符*
(对于nmPtr
也是如此,以及该函数中其他指针的方式):
*nmPtr =(*nyPtr*12);