ok what i need help here is with calling the function 'inputinfo' in the 'main()'. what am i doing wrong here..? and also if i try the same method with the rest of the functions will there be errors as well? (program is obviously incomplete working on it now, i just want to get each function working bit by bit in the main() by calling each one. the question requires me to write functions for each operation such as inputting numbers and printing out numbers or formulae. i just need to call them now in the main(). thanks for the help.
Code:
#include <stdio.h>
#include <math.h>
int isValidInput(double amount, double annualeRate, int nmonths);
float interestmonth(float IM, int IY); /* declaration */
int valueP(int P, int IM, int NM);
int valueQ(int Q, int P);
int monthlypayment(int MP, int PR, int IM, int Q);
void inputInfo(double *amountPtr, double *annualRatePtr, int *nmonthsPtr);
main ()
{
int NM, IM, PR, P, Q, MP;
int *nmonthsPtr;
double *amountPtr, *annualRatePtr;
float IY;
inputInfo(double *amountPtr, double *annualRatePtr, int *nmonthsPtr)
return 0;
}
void inputInfo(double *amountPtr, double *annualRatePtr, int *nmonthsPtr)
{ /*Use the double type specifier to define an identifier to be a floating-point data type*/
int *amountPtr = NULL; /*initializing pointers*/
float *annualRatePtr = NULL;
int *nmonthsPtr = NULL;
amountPtr = &PR; /*assigning address of a variable to a*/
annualRatePtr = &IY; /*compatible pointer using the & operator*/
nmonthsPtr = &NM;
printf("1. Amount of loan (Principal)?"); /* a) */
scanf("%d", &PR); /*input numbers*/
printf("2. Interest rate per year (in percent)?");
scanf("%f", &IY);
printf("3. Number of months to amortize loan?");
scanf("%d", &NM);
printf("Input entered\n 1. %d\n 2. %f\n 3. %d\n", PR, IY, NM); /*prints numbers entered*/
scanf("%d");
}
/*functions: math formulae*/
int isValidInput (double amount, double annualRate, int nmonths)
{
if(0 > amount || annualRate || nmonths > 100)
{
return true; /* validating entry of amount */
} /* annualRate and nmonths */
else
{
return false;
}
}
float interestmonth(float IM, float IY)
{ /*interest month equation*/
IM = (IY) / (12 * 100);
}
int valueP(int P, int IM, int NM) /*equation for valueP*/
{
P = ((1 + IM)pow(NM));
}
int valueQ(int Q, int P)
{ /* equation for valueQ*/
Q = P / (P - 1);
}
int monthlypayment(int MP, int PR, int IM, int Q) /*equation for monthlypayment*/
{
MP = (PR * IM * Q);
}