What is wrong with these pointers (C programming)?
include
#include
#define TAX_RATE 1.25
#define UTILITY_COST 300.0
#define INSURANCE_COST 550.0
void input(float*, float*, float*);
void calc(float, float, float, float, float, float, float, float);
float calcDplomo(float, float, float, float*, float*, float*, float*, float*);
void output(float, float, float, float, float, float, float, float);
int main(void)
{
float sellp;
float anir;
float loand;
float downp;
float amtl;
float mortg;
float propt;
float mtot;
input(&sellp, &anir, &loand);
calc(sellp, anir, loand, downp, amtl, mortg, propt, mtot);
output(sellp, anir, loand, downp, amtl, mortg, propt, mtot);
return 0;
}
void input(float* sellp, float* anir, float* loand)
{
printf(“\n\t\t Brian’s Mortgage Calculation Program\n”);
printf(“\nEnter the property’s selling price: \n”);
scanf(“%f”,sellp);
printf(“\nEnter the annual rate of interest: \n”);
scanf(“%f”,anir);
printf(“\nEnter the duration (years) of the loan: \n”);
scanf(“%f”,loand);
return;
}
void calc(float sellp, float anir, float loand, float downp, float amtl, float mortg, float propt, float mtot)
{
calcDplomo(sellp, anir, loand, &downp, &amtl, &mortg, &propt, &mtot);
return;
}
float calcDplomo(float sellp, float anir, float loand, float* downp, float* amtl, float* mortg, float* propt, float* mtot)
{
float cdown = .2;
float mins;
*propt = sellp * (TAX_RATE/100)/12;
mins = INSURANCE_COST/12;
*mtot = *mortg + UTILITY_COST + *propt + mins;
*downp = sellp * cdown;
*amtl = sellp – *downp;
*mortg = *amtl * anir/12*(1+anir/12) * loand *12/(1+anir/12) * loand *12-1;
return mins;
}
void output(float sellp, float anir, float loand, float downp, float amtl, float mortg, float propt, float mtot)
{
printf(“\nMONTHLY COST OF HOUSE\n”);
printf(“\nSELLING PRICE $ %9.2f”,sellp);
printf(“\nDOWN PAYMENT %9.2f”,downp);
printf(“\nAMOUNT OF LOAN %9.2f”,amtl);
printf(“\nINTEREST RATE %9.1f%%”,anir);
printf(“\nTAX RATE %9.1f%%”,TAX_RATE);
printf(“\nDURATION OF LOAN (YEARS) %9.0f\n”,loand);
printf(“\nMONTHLY PAYMENT\n”);
printf(“\nMORTGAGE %9.2f”,mortg);
printf(“\nUTILITIES %9.2f”,UTILITY_COST);
printf(“\nPROPERTY TAXES %9.2f”,propt);
printf(“\nUTILITIES %9.2f\n”,INSURANCE_COST);
printf(” __________”);
printf(” $ %9.2f\n”,mtot);
return;
}
Trial run:
Brian’s Mortgage Calculation Program
Enter the property’s selling price:
600000
Enter the annual rate of interest:
2.2
Enter the duration (years) of the loan:
30
MONTHLY COST OF HOUSE
SELLING PRICE $ 600000.00
DOWN PAYMENT -107374176.00
AMOUNT OF LOAN -107374176.00
INTEREST RATE 2.2%
TAX RATE 1.3%
DURATION OF LOAN (YEARS) 30
MONTHLY PAYMENT
MORTGAGE -107374176.00
UTILITIES 300.00
PROPERTY TAXES -107374176.00
UTILITIES 550.00
__________
$ -107374176.00
Press any key to continue
I know it has to do with the function call in void calc calcDplomo(sellp, anir, loand, &downp, &amtl, &mortg, &propt, &mtot); But how do I fix it?