#include
main()
{ FILE*wptr;
int ans=1,poh;
float rate,moncost,mpm,dpm,borrow,total_int,total_pm,;
wptr = fopen("data.out","w");
printf("\t\t Rate \t\t Monthly Cost \n");
printf("\t\t 6.0% \t\t $6.00 \n");
printf("\t\t 7.0% \t\t $6.66 \n");
printf("\t\t 8.0% \t\t $7.34 \n");
printf("\t\t 9.0% \t\t $8.05 \n");
printf("\t\t 10.0% \t\t $8.78 \n");
printf("\t\t 10.5% \t\t $9.15 \n");
printf("\t\t 11.0% \t\t $9.52 \n");
while(ans==1)
{
printf(" Price of home:");
scanf("%d",&poh);
printf("\n Interest rate:");
scanf("%f",&rate);{
if(rate = 6)
moncost = 6;
else if(rate = 7)
moncost = 6.66;
else if(rate = 8)
moncost = 7.34;
else if(rate = 9)
moncost = 8.05;
else if(rate = 10)
moncost = 8.78;
else if(rate = 10.5)
moncost = 9.15;
else if(rate = 11)
moncost = 9.52;}
dpm = poh * .2;
borrow = poh - dpm;
mpm = borrow * moncost / 1000;
total_int = mpm * 360 - poh;
total_pm = mpm * 360;
printf("\n Your down payment: %f",dpm);
printf("\n Amount financed: %f",borrow);
printf("\n Your monthly payment: %f",mpm);
printf("\n Total interest: %f",total_int);
printf("\n Total payment: %f",total_pm);
fprintf(wptr,"\t Payment calculations");
fprintf(wptr,"\n Price of home: \t %d",poh);
fprintf(wptr,"\n Interest rate \t %f",rate);
fprintf(wptr,"\n Percent of down payment: \t 20%");
fprintf(wptr,"\n\n Down payment: \t %f",dpm);
fprintf(wptr,"\n Amount financed: \t %f",borrow);
fprintf(wptr,"\n Monthly payment: \t %f",mpm);
fprintf(wptr,"\n Total interest: \t %f",total_int);
fprintf(wptr,"\n Total payment: \t %f",total_pm);
printf("\n 1 to continue, 0 to stop");
scanf("%d",&ans);
}
} //end of main